response.redirect not redirecting to full domain name
I'm having an issue Redirecting to the same domain.
For example, the redirection takes place on ServerA.Domain.com/Folder/application.aspx. However, the program redirects me to ServerA/Folder/application.aspx.
The application works fine on this domain, but I'm forced to relogin.
What can I do to force the r开发者_JS百科edirection to the same domain??
I am using asp.net 3.5
Added My Redirect looks as follows:
Response.Redirect("/Folder/application.aspx?");
What if you just add the tilde (~) character and a call to ResolveClientUrl to the redirect?
Response.Redirect(this.ResolveClientUrl("~/Folder/application.aspx?"));
Does that take care of the problem?
It looks like your on a sub domain trying to redirect to a folder on the sub domain. I believe you need to use the fully qualified URL:
Response.Redirect("http://ServerA.Domain.com/Folder/application.aspx?");
What's happening is your sub domain is a folder on the main site, which your telling your app to redirect to. It doesn't know that you have a sub domain set up which accesses that folder by default.
Update:
Try using HttpContext.Current.Request.Url.xxxxx
and then appending to that. This way you can probably get your sub domain route and redirect in the format you want.
You could try using
Server.Transfer("/Folder/application.aspx?");
ResolveClientUrl returns a relative path to the current url; ResolveUrl returns the absolute path. So ResolveUrl may work better in case it is called within a usercontrol under another folder:
Response.Redirect(this.ResolveUrl("~/Folder/application.aspx?"));
精彩评论