2
我對Formsauthentication和我的ajax調用有問題。 我喜歡Formsauthenticaction爲一個正常的asp.net網站工作的方式。對單個頁面應該禁用Formsauthentication
但是我在我的asp.net網站上有一個頁面,它使用AJAX進行調用。此頁面在某些情況下會將Response StatusCode設置爲未授權(401)。
Response.StatusCode = 401;
Response.End();
現在響應應該結束,我希望看到這401狀態碼傳播到前端。然而,Formsauthentication另有決定,並將此狀態更改爲302並重定向到登錄頁面。 因此,我無法檢查我的用戶界面上的狀態401。
爲了進一步通知你:我在IIS 7上運行的asp.net 4.0網站(不 MVC)
我試圖配置我的web.config與以下節點:
<location path="mypage.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
但我想通過設置未授權狀態觸發Formsauthentication模塊。
很好讀,我想在我的方案中的「DoNotRedirectLoginModule」是正確的做法。非常感謝這個非常有用的答案。 –