How to redirect user another .NET page (in same domain) but not change URL in addressbar?

2.2k Views Asked by At

I'm working on a company website that allows users to have their own homepage under the same domain. The URL would look similar to http://mydomain.com/UserName We have each user's content saved in a database which gets displayed on a page be located in http://mydomain.com/users/default.aspx (it grabs the user's content by looking up the URL in the database)

I want the URL to stay the same in the address bar so it looks like each user has their own folder.

I've tried using Server.Transfer but my session variables end up being nothing. RewritePath works but the URL in the address bar changes. I can't do the code in a 404 page because the address bar will show 404.aspx?aspxerrorpath={requestedURL}

My main goal is to redirect and not to lose what's in the address bar. I'm using ASP.NET (if aspx extension didn't give it away LOL)

3

There are 3 best solutions below

2
On BEST ANSWER

You could use Routing or Rewriting to map the user url to your asp script. This way different url's can go the the same aspx script.

Rewriting http://www.helicontech.com/isapi_rewrite/doc/RewriteRule.htm

3
On

You can achieve what you want by having a Server.Execute in the default.aspx, eg:

<%Server.Execute("path to another aspx page you wish to display inline while keeping the URL in tact")%>
2
On

You can't exactly do that. The URL is what users rely on recognizing the server. But you can show that content on the same page. You can use a fullscreen iframe and load the content in it and show it to the user and it's pretty easy to implement.

EDIT: Note that you don't even need an iframe. If you want to show some other page in your website, you can download its content and output it. (You need some changes though). But the more simple method is to use an iframe.