好的,我必須在這裏丟失一些明顯的東西,但無法在任何地方找到答案。RedirectFromLoginPage忽略ReturnUrl
我在本地機器上的.Net 4中使用FormsAuthentication。當我嘗試訪問受保護的頁面時,.Net會將我重定向到login.aspx並在查詢字符串中追加ReturnUrl。例如。 /pages/security/login.aspx?ReturnUrl=%2fPages%2fFriends.aspx
當我用正確的細節登錄時,我沒有被重定向到ReturnUrl--而是被重定向到web中的任何東西。 config defaultUrl參數。
我的web.config文件看起來是這樣的:
<authentication mode="Forms">
<forms loginUrl="/pages/security/login.aspx" defaultUrl="/default.aspx" timeout="129600" />
</authentication>
這裏的重定向行:
FormsAuthentication.RedirectFromLoginPage(userID.ToString(), rememberMe);
無論我把defaultUrl在web.config中就是我重定向到。實際上,當我檢查時,這也是FormsAuthenticaton.GetRedirectUrl中的值。看起來.Net忽略了ReturnUrl,但我想不出爲什麼。
任何想法?