asp.net – 如何使用Forms身份验证将用户重定向到特定页面
发布时间:2020-12-16 09:42:16 所属栏目:asp.Net 来源:网络整理
导读:我想配置应用程序并阻止用户直接访问应用程序中的任何页面而无需登录,但任何用户都可以访问网站主页. 但是当我运行主页,登录页面或网站的任何页面时,我收到此错误: – 无法访问请求的页面,因为页面的相关配置数据无效. 我无法找出我犯错误的地方.我发布了我
我想配置应用程序并阻止用户直接访问应用程序中的任何页面而无需登录,但任何用户都可以访问网站主页.
但是当我运行主页,登录页面或网站的任何页面时,我收到此错误: – 无法访问请求的页面,因为页面的相关配置数据无效. 我无法找出我犯错误的地方.我发布了我的web.config文件.看看它.看看我在哪里弄错了,解决方案是什么. ?web.config中 <?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application,please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <connectionStrings> <add name="ConnectionString" connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> <authentication mode="Forms"> <forms loginUrl="/Registration/LoginPage.aspx"> </forms> </authentication> <system.web> <compilation debug="true" targetFramework="4.5.2" /> <httpRuntime targetFramework="4.5.2" /> </system.web> <location path="FIRST PAGE"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web> </location> <location path="Registration"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location> <location path="AdminHome"> <system.web> <authorization> <allow users="admin"/> <deny users="*"/> </authorization> </system.web> </location> <location path="Student"> <system.web> <authorization> <allow roles="Student"/> <deny users="*"/> </authorization> </system.web> </location> <location path="Teacher"> <system.web> <authorization> <allow roles="Teacher"/> <deny users="*"/> </authorization> </system.web> </location> <appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/> </appSettings> </configuration> ?错误 该网站的主页位于FIRST PAGE文件夹下,登录和注册页面位于文件夹Registration下 解决方法
< authentication>您的配置的一部分应该在< system.web>内.部分
MSDN authentication Element 只需编辑您的web.config: <system.web> <authentication mode="Forms"> <forms loginUrl="/Registration/LoginPage.aspx"> </forms> </authentication> <compilation debug="true" targetFramework="4.5.2" /> <httpRuntime targetFramework="4.5.2" /> </system.web> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 将角色添加到ADFS IPrincipal
- Asp.net视图状态MAC的验证失败
- asp.net-mvc – 我应该将LightSwitch用于大型项目吗?
- asp.net-mvc-3 – MVC3,多文件上传,模型绑定
- asp.net – “填充无效,不能删除”异常WebResource.axd
- asp.net-mvc – 从Asp.Net Mvc应用程序找不到DataContractJ
- asp.net – 从中??等信任环境的Web.config读取system.net/m
- asp.net-mvc-3 – MVC 3重定向到子域上的操作
- .net core 使用Rotativa创建PDF文档
- asp.net-mvc-3 – Telerik().ScriptRegistrar()如何防止加载