Forms Authentication Ignoring Default Document

后端 未结 7 1605
无人共我
无人共我 2020-11-28 10:01

I have spent a day and a half trying to resolve this issue. Bascially have an ASP.net website with Forms Authentication on IIS7 using Framework 4.0.

The Authorizati

7条回答
  •  青春惊慌失措
    2020-11-28 10:28

    What I ended up doing to fix this is writing a few lines of code in my login page to check for a Request.QueryString["ReturnUrl"] of "/". If it found that, then it redirected to default.aspx.

    I couldn't find ANY way to make forms authentication not intercept calls without a page specified (e.g. www.mysite.com). :( I even tried .NET 4 URL Routing and that didn't prevent Forms Authentication from hijacking the request either.

    Below is the code I used in login.aspx:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(IsPostBack || IsAsync))
        {
            string returnUrl = Request.QueryString["ReturnUrl"];
            if (returnUrl != null)
                if (returnUrl == "/")
                    Response.Redirect("default.aspx");
        }
    }
    

提交回复
热议问题