开发者

.NET Response.Redirect not working properly on new server

we are running into an issue with our ASP server.

If you try to access a password protected page it does a security check and redirects you if you are not logged in, retaining the URL (ie. Members/MemberLogin.aspx?doc=/PodCast/Default.aspx)

The vb script places the "/PodCast/De开发者_JAVA百科fault.aspx" in a variable and holds it until the login process is complete.

Once the user types in their username and password it is suppose to do a Response.Redirect(strRedirectURL) and go to the "/PodCast/Default.aspx" but instead it goes to the default.aspx page for logging in successfully.

The kicker is, I know the code is 100% correct becuase it was working on our previous server, but when we pushed all the data onto this server, everything works BUT that piece.

Any suggestions, would be great!

Thanks everyone!


Do you use custom redirection code? The default querystring parameter ASP.NET uses for redirection after login is ReturnUrl.

You gave the example: Members/MemberLogin.aspx?doc=/PodCast/Default.aspx.

Based on this, I would assume once logged in, the .net framework checks the value of Request.QueryString["ReturnUrl"] and finding it empty, so the site redirects to the base url.

If for some reason you are constructing a non-standard url using doc as your querystring parameter, you could hook into your Login control's OnLogin event, such as:

markup:

<asp:Login id="Login1" runat="server" OnLoggedIn="Login1_LoggedIn" />

code:

protected void Login1_LoggedIn(object sender, EventArgs e)
{
    string url = Request.QueryString["doc"];
    if(!string.IsNullOrEmpty(url))
    {
        Response.Redirect(url);
    }
}


If your postback mechanism (like a button) exists inside an updatepanel, you need to set the trigger asp:PostBackTrigger ControlID="XXXX" /

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜