I am trying to retrospectively plug in Forms Authentication to an ASP.Net project that was originally created with the no authentication template using VS 2013 and ASP.Net 4.0
I have followed the advice on MSDN and added this to my Web Config under system.web
<authentication mode="Forms">
<forms loginUrl="Logon.aspx" name=".ASPXFORMSAUTH">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
When I launch the site (IIS 7) the URL redirects to the Logon.aspx page but then I get a Error message 401.2.: Unauthorized: Logon failed due to server configuration.
In IIS I have the website set for Anonymous and Forms based authentication enabled.
Am I missing something here? I think there might be a hidden setting somewhere that ASP.net sets when he no authentication template is used?
Edit : The issue is the same as reported here: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/2920a4e2-775a-4aa7-bfff-4931fa0a4e9a/azure-website-forms-authentication-issue?forum=windowsazurewebsitespreview
It looks like there is an issue with Forms authentication not working with ASP.net template projects. :(. It works fine with the "Empty ASP.Net web application" but any of the others runs into this issue.
经过大量挖掘之后,答案是删除ASP.net模板随附的Friendly URLS Nuget。
If using friendly url ( just remove the .aspx from the loginUrl in web.config)
Change the web.config file Authentication. In this case it will be
<authentication mode="Forms">
<forms loginUrl="Logon" name=".ASPXFORMSAUTH">
</forms>
</authentication>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.