polohy
polohy

Reputation: 287

asp.net redirect to another location than set in navigateURL

in my asp.net website I have menu control and there are those items:

<asp:menuitem ... navigateURL="~/Admin/admin.aspx">
<asp:menuitem ... navigateURL="~/Admin/search.aspx">

I want force the asp.net think (or display in web browser adress bar), that I am on admin.aspx, but actually be redirected to search.aspx. Is it somehow possible ?

Thanks.

Upvotes: 2

Views: 1179

Answers (3)

Icarus
Icarus

Reputation: 63966

Doing that with the markup you showed, no, it's not possible. You'll need to either use an <iframe> setting the src property via javascript or you do it from code-behind using Server.Transfer as opposed to Response.Redirect.

Upvotes: 1

bdparrish
bdparrish

Reputation: 2764

You can setup customized routing if you would like, but that will still display "search.aspx" in the address bar. If you want to fake the admin.aspx as search.aspx, then add your search controls in to the admin.aspx page and hide the admin controls. If you are trying to "spoof" admin.aspx, like you would an e-mail address or something, then I would direct to not StackOverflow.

Upvotes: 0

ilivewithian
ilivewithian

Reputation: 19702

URL rewriting sounds like it's what you are after:

http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx

Failing that you might be able to build some custom logic into your page and use Server.Transfer to change page, without changing the URL.

Upvotes: 1

Related Questions