1

I'm currently redirecting a page using

Response.Redirect("URL");

this works great, however it changes the url too. For example:

http://localhost/index.aspx

Redirected to: test.aspx will change the url to:

http://localhost/test.aspx

Is it possbile to redirect the content without changing the URL?... so the Url will be:

http://localhost/test.aspx

BUT the content would of been redirected to

test.aspx

Thank you.

4
  • 1
    There are ways of doing this (e.g. Server.Transfer) but they all have drawbacks depending on the specifics of your scenario. The reason for that being that this is not really what those tools are for and is quite an odd thing to try to do. Can I ask why you want to do this? It seems like a bad idea. Commented Nov 26, 2014 at 9:51
  • It was just a check to see if the application was in maintenance mode. And if it was, to display that maintenance content.. But I wanted the users to be able to refresh the application and still be on the page that they was on in the first place. Commented Nov 26, 2014 at 9:55
  • 2
    Perhaps you could consider the euchy iFrame alternative, keep the URL the same while serving different content... or perhaps an ajax update panel may be the better solution, or even a modal popup Commented Nov 26, 2014 at 10:00
  • Thanks, Okay then, I shall look a bit more in depth for this solution. Commented Nov 26, 2014 at 10:01

2 Answers 2

1

Try to use Server.Transfer(URL); to avoid changing the url.

More info here.

And also check the differences at this post and this one.

Make sure that this solution meets your needs.

Sign up to request clarification or add additional context in comments.

Comments

1

Use Server.Transfer This will show the content of default.aspx page, but it will not change the url

Server.Transfer("Default.aspx");

4 Comments

Always love the downvote, plaese explain me why ? :)
Not my downvote, but blindly recommending Server.Transfer without further insight into the asker's scenario is not helping anyone.
@AntP he asks for redirection to content of another page without changing the url. This is the scenario, Server.Transfer provides this logic !
It's not that simple. Server.Transfer is applicable in very specific scenarios. Transferring the control of a single request to a separate .aspx file is not the only way of conditionally rendering different content and - in most cases - it's not the right one and has plenty of pitfalls. The use case/requirement needs to be interrogated further (i.e. displaying content from another page under the original page's URL is probably not the best solution to the problem in the first place).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.