2023-02-16 347
我尝试在我们现有数据库的顶部实现ASP.NET身份验证和授权.
我们有一个网站调用WebService来获取其数据.要使用WebService,我需要提供用户名和密码.
知道这一点,我决定实现IINTINTITY和IPRINCIPAL来存储加密密码,并在执行WebService调用时提供它.
在未来,我们可能希望使用更多内置的ASP.NET安全性,因此我实现了成员资格和角色提供程序并覆盖我需要的(validateUser和getroles)
虽然,由于成员资格提供商实现验证了用户,但我仍然将自己的自定义性设置为Context.User能够在需要时检索其密码.
只要允许用户访问页面,它就会完美地工作.但是当用户被拒绝时,框架而不是抛出acceptionedException,而不是抛出inscordedEdeDeption,而是在我的自定义事件上划分序列化异常.
我找到了一个与此链接上描述的更多详细信息 ,但没有答案已经发布.
我的例外与上面的链接完全相同,
Type is not resolved for member'CW.CustomAuthentication.CWIdentity,CW.CustomAuthentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.Serialization.SerializationException: Type is not resolved for member 'CW.CustomAuthentication.CWIdentity,CW.CustomAuthentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SerializationException: Type is not resolved for member 'CW.CustomAuthentication.CWIdentity,CW.CustomAuthentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.]
Microsoft.VisualStudio.WebHost.Connection.get_RemoteIP() +0
Microsoft.VisualStudio.WebHost.Request.GetRemoteAddress() +65
System.Web.HttpRequest.get_UserHostAddress() +18
System.Web.HttpRequest.get_IsLocal() +13
System.Web.Configuration.CustomErrorsSection.CustomErrorsEnabled(HttpRequest request) +86
System.Web.HttpContext.get_IsCustomErrorEnabled() +42
System.Web.Configuration.UrlAuthFailedErrorFormatter.GetErrorText(HttpContext context) +16
System.Web.Security.UrlAuthorizationModule.WriteErrorMessage(HttpContext context) +29
System.Web.Security.UrlAuthorizationModule.OnEnter(Object source, EventArgs eventArgs) +8777783
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
是否正确使用会员资格和定制的IINTITY和IPRINCIPALE同时?
如果没有,如果我使用会员资格和角色提供者,则在其中添加属性或其他userdata?
最好的问候,
斯蒂芬erbrech
经过一些更多的测试,根据我发布的链接所说的,似乎只有在Visual Studio的调试模式下运行时才发生此错误.如果我将项目设置为在IIS中运行,则错误消失,安全实现按预期工作.
—是在Visual Studio中实现的轻量级Web服务器中的错误吗?—
编辑:
您可以进入Web项目的属性,转到”Web”选项卡,然后选中”使用本地IIS服务器”.但是,这将要求您将Visual Studio作为管理员运行,并在计算机上安装IIS,以便在加载项目时,VS可以在本地IIS服务器中创建虚拟目录.
在我的情况下,我只需继承”MarshalByRefObject”.
public class IcmtrIdentity : MarshalByRefObject, IIdentity
{
...
}
这可能不是正确的答案,但我也有这个问题,但是固定它.
最初,我只有一个继承GenericIdentity的自定义类(或采用IIdentity).当我终于创建了一个继承GenericPrincipal(或inclimagered IPrincipal)的自定义类时,它都有工作?
我的CustomPrincipal类没有什么,但是继承自GenericPrincipal,并且有一个称为基本构造函数的构造函数.
CustomPrincipal和CustomIdentity类没有判例任何Serialization或ISerializable的东西.然后,我的课程都非常基础.
以上所述是小编给大家介绍的在ASP.NET中,当用户被拒绝时,在'CustomIdentity'上出现SerializationException。,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!
原文链接:https://77isp.com/post/34054.html
=========================================
https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。
数据库技术 2022-03-28
网站技术 2022-11-26
网站技术 2023-01-07
网站技术 2022-11-17
Windows相关 2022-02-23
网站技术 2023-01-14
Windows相关 2022-02-16
Windows相关 2022-02-16
Linux相关 2022-02-27
数据库技术 2022-02-20
抠敌 2023年10月23日
嚼餐 2023年10月23日
男忌 2023年10月22日
瓮仆 2023年10月22日
簿偌 2023年10月22日
扫码二维码
获取最新动态