C# 应为单个页面禁用Formsauthentication
我对Formsauthentication和ajax调用有问题。 我喜欢FormsAuthentication在普通asp.net网站上的工作方式 然而,我的asp.net网站中有一个页面使用AJAX调用。在某些情况下,此页面会将响应状态代码设置为未经授权(401) 现在响应应该结束了,我希望看到401状态代码传播到前端。但是,Formsauthentication会做出相反的决定,并将此状态更改为302并重定向到登录页面。 因此,我无法检查UI上的状态401 进一步通知您:我正在IIS 7上运行一个asp.net 4.0网站(不是MVC) 我尝试使用以下节点配置我的web.config:C# 应为单个页面禁用Formsauthentication,c#,asp.net,ajax,forms-authentication,formsauthentication,C#,Asp.net,Ajax,Forms Authentication,Formsauthentication,我对Formsauthentication和ajax调用有问题。 我喜欢FormsAuthentication在普通asp.net网站上的工作方式 然而,我的asp.net网站中有一个页面使用AJAX调用。在某些情况下,此页面会将响应状态代码设置为未经授权(401) 现在响应应该结束了,我希望看到401状态代码传播到前端。但是,Formsauthentication会做出相反的决定,并将此状态更改为302并重定向到登录页面。 因此,我无法检查UI上的状态401 进一步通知您:我正在IIS 7上运
<location path="mypage.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
但我猜,通过设置未经授权的状态,会触发Formsauthentication模块。以下是一些建议的解决方案
读得不错,我认为在我的场景中,“DoNotRedirectLoginModule”是正确的方法。非常感谢这个非常有用的答案。
<location path="mypage.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>