Sunil
Sunil

Reputation: 21406

Redirect a user when he or she tries to navigate to a page in ASP.NET website

Is it possible to re-direct a request for a page 'XYZ.aspx' to 'ABC.aspx', without writing any code? We are using ASP.Net 4.0 with IIS 7.5.

The idea is that we want to remove XYZ.aspx page from our website, and if users still use old bookmarks that point to XYZ.aspx, then we want them to be taken to ABC.aspx in an automated manner.

Upvotes: 0

Views: 110

Answers (3)

Sunil
Sunil

Reputation: 21406

I found the answer. One needs to use the following in web config, and that's it.

<location path="XYZ.aspx">
<system.webServer>
  <httpRedirect enabled="true" destination="http://localhost/mysite/ABC.aspx" httpResponseStatus="Permanent" />
</system.webServer>

UPDATE : This will also work if any query string parameters are passed to the page XYZ.aspx.

Upvotes: 0

Arif YILMAZ
Arif YILMAZ

Reputation: 5866

you can forward the user through web.config file or you can do it through IIS too. but I I were you I would use web.config. in shared hosting u cannot touch IIS.

Upvotes: 1

Paritosh
Paritosh

Reputation: 4503

there seems to be a few ways, link should hopefully help you out. http://www.trainsignal.com/blog/iis7-redirect-windows-server-2008

Upvotes: 2

Related Questions