在ASP.NET中拒绝用户时,’CustomIdentity’上的SerializationExc
发布时间:2020-12-15 20:27:10 所属栏目:asp.Net 来源:网络整理
导读:我尝试在现有数据库的基础上实现ASP.NET身份验证和授权. 我们有一个网站调用webservice来获取其数据.要使用Web服务,我需要提供用户名和密码. 知道这一点,我决定实施IIdentity和IPrincipal来存储加密的密码,并能够在执行webservice调用时提供它. 在将来,我们
我尝试在现有数据库的基础上实现ASP.NET身份验证和授权.
我们有一个网站调用webservice来获取其数据.要使用Web服务,我需要提供用户名和密码. 知道这一点,我决定实施IIdentity和IPrincipal来存储加密的密码,并能够在执行webservice调用时提供它. 在将来,我们可能希望使用更多asp.net的内置安全性,因此我实现了成员资格和角色提供程序,并覆盖了我需要的内容(ValidateUser和GetRoles) 但是,在通过成员资格提供程序实现验证用户之后,我仍然将自己的CustomIdentity设置为Context.User,以便能够在需要时检索其密码. 只要允许用户访问该页面,它就能完美运行.但是当用户被拒绝时,框架会在我的CustomIdentity上抛出序列化异常,而不是抛出AccessDeniedException. 我的例外情况与上面的链接完全相同 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,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,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 同时使用会员资格和自定义IIdentity和IPrincipal是否正确? 最好的祝福, Stephane Erbrech 解决方法
经过一些更多的测试,根据我发布的链接说,似乎只有当我从visual studio运行调试模式时才会发生此错误.如果我将项目设置为在IIS中运行,则错误消失,安全实现按预期工作.
—这是Visual Studio中实现的轻量级网络服务器中的一个错误吗?— 编辑:您可以进入Web项目的属性,转到“Web”选项卡,然后选中“使用本地IIS服务器”.但是,这将要求您以管理员身份运行Visual Studio并在计算机上安装IIS,以便VS在加载项目时可以在本地IIS服务器中创建虚拟目录. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 发布网站项目时Temp路径太长
- asp.net-mvc – ASP.NET MVC:对动作执行AJAX请求
- asp.net-mvc-3 – SSL会在我的asp.net mvc3 web应用程序中加
- asp.net – 使用AJAX填充下拉列表
- asp.net-core – SignalR Authorize属性不适用于cookie身份
- ASP.NET ModalPopupExtender单击“事件”
- asp.net – 按钮点击后如何启动另一个aspx网页?
- 如何使reCAPTCHA与ASP.Net(验证码)中的ValidationGroup一起
- asp.net-mvc – Ajax.ActionLink使用背景不透明度加载图像定
- 记一次ASP.NET MVC性能优化(实际项目中)
推荐文章
站长推荐
- asp-classic – XP经典ASP上的IIS 5.1似乎处于单
- 如何在ASP.Net MVC标记中克服我对<%%>的恐惧?
- asp.net-web-api – 无法识别Web Api [可查询]属
- asp.net – 具有齐次参数数组的MVC路由
- asp.net-mvc-3 – 在Html.BeginForm()中使用DELE
- asp.net – Nlog数据库目标 – 是否使用keepConn
- 验证 – ASP.NET MVC 4避免生成datetime的data-v
- 如何获取对默认ASP.NET页面处理程序或Web服务处理
- 我应该为ASP.net创建一个JQuery服务器控件,以便在
- telerik – ASP.NET MVC2富文本编辑器
热点阅读