返回链接中不工作的URL

本文关键字:URL 工作 链接 返回 | 更新日期: 2023-09-27 18:18:25

我正在使用ASP.net,并且在登录后重定向原始请求的URL时遇到问题。URL在地址栏中清楚地显示,但在签名时它需要我默认。Aspx每次:

http://development-4/login.aspx?ReturnUrl=%2fControls%2fFinancial%2fAddressBook.aspx

返回链接中不工作的URL

. net框架已经使用'ReturnUrl'值自动处理重定向。除非你要把用户带到他们想去的地方,否则使用以下命令将他们重定向到他们所请求的页面。

将'userName'替换为登录时提供的用户名。' ispersistent '指的是cookie是应该保存浏览器会话,还是在会话窗口关闭时删除会话。

FormsAuthentication.RedirectFromLoginPage("userName", isPersistant); 

如果您选择将用户带到其他地方,您的代码应该与此类似。

FormsAuthentication.SetAuthCookie("userName", isPersistant);
Response.Redirect("~/SomePage.aspx");

因为您没有提供太多背景信息,所以我将添加以下配置。你应该有类似的。

<system.web>
    <authentication mode="Forms">
        <forms name="loginCookieName" loginUrl="~/login.aspx" protection="All" timeout="60" path="/" />
    </authentication>
    <authorization>
        <deny users="?" />
    </authorization>
</system.web>
<location path="login.aspx">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>