FormsAuthentication.RedirectFromLoginPage重定向到default.aspx

时间:2014-01-08 15:35:24

标签: asp.net

我正在使用表单身份验证来验证用户身份,然后将用户重定向到     欢迎页面,这是Welcome.aspx。当用户凭据有效时,则该用户     将被重定向到Welcome.aspx页面。

我正在使用    FormsAuthentication.RedirectFromLoginPage()方法将用户重定向到欢迎    页面,但由于某种原因,FormsAuthentication.RedirectFromLoginPage()方法是    将用户重定向到Default.aspx。

Web.Config代码:

 <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <authorization>
      <deny users="?"/>
    </authorization>
    <authentication mode="Forms">
      <forms loginUrl="~/Login.aspx" timeout="2880"  defaultUrl="~/Welcome.aspx"/>
    </authentication>

3 个答案:

答案 0 :(得分:0)

  

如果使用RedirectFromLoginPage方法,则使用DefaultUrl属性   请求中不包含任何返回URL。

所以您可能有Default.aspx作为返回网址,或者您可能已将Default.aspx设置为defaultDocument

答案 1 :(得分:0)

这会将用户重定向到他们刚查看的页面。这就是为什么它会回到default.aspx。您只需要重定向到实际的欢迎页面 - 静态。

答案 2 :(得分:0)

您只允许授权用户通过指定<deny users="?" />

来访问这些页面

将此添加到您的web.config文件中以进行welcome.aspx重定向。

<location path="Welcome.aspx">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>