简体   繁体   中英

Response.Redirect doesn't work in login page

when trying to access a search function button in my site master page while in the login page, the page just gets refreshed, using Server.Transfer instead throws the "Error executing child request for " error, accessing from everywhere else is okay, could this be I can't get out of the 'secure zone' while in the login page? Does this has anything to do with the web.config, I am not sure which portion of code should I look into either.

Please kindly advice. Thanks.

This is click event:

  protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text != "")
            {
                Session["txtValue"] = TextBox1.Text;
                Response.Redirect("ProductSearch.aspx");
            }
        }     

Your login page should not use the site master page. (Nor should any error pages). In that way, the various code you run in the master page will not need to run in the unauthorized context.

The web.config will always send the requests back to the login page if the user is unauthorized. If your code does run, you can find loops leading to stack overflows.

Is the page you're trying to navigate to (ProductSearch.aspx) protected (ie do you need to first login to access it)? If so, and if you are not yet logged in then any attempt to navigate to ProductSearch.aspx would automatically redirect you back to the login page (as you describe).

Cheers, Wayne.

First, I would make sure there is nothing in your ProductSearch page that would redirect you, maybe based on your session state or something. Also check the master page to make sure its not that redirecting you. Finally, if its still not working, I'd use the debugger and just step through your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM