dbjoe
dbjoe

Reputation: 65

Adding redirects in asp.net

I am looking for some advice to help with the following scenario (I am still learning VB.net with ASP) I have looked on Google but I have hit a dead end now.

the first issue that I am having is trying to redirect www.samplesite.com/press.aspx to www.samplesite.com/press/press.aspx I have tried to use Rewrite Rules in the web.config without success.

the next issue I am having is I want any request for the homepage not using the default url to redirect to the default url, it also needs to preserve the query string if any. for example please see below:

https://samplesite.com/home.aspx?key=value

Returns a 301 redirect to:

https://samplesite.com/?key=value

And:

https://samplesite.com/home.aspx/anything?key=value

Redirects to:

https://samplesite.com/?key=value

I would be grateful for any assistance on this.

Upvotes: 0

Views: 96

Answers (2)

Mubarek
Mubarek

Reputation: 2689

I think you're looking for asp.net routing and want to define custom url patterns or generate urls based on route parameters. These should give you some hints:

ASP.NET Routing

URL Routing

Upvotes: 1

Daniel Suchan
Daniel Suchan

Reputation: 61

Try using:

<meta http-equiv="refresh" content="0; url=http://samplesite.com/some/route" />

Note: Place it in the head section.

Upvotes: 0

Related Questions