We have redesigned the structure to a website which has several business units. Now I want to redirect (301) to the new page.
IE:
was http://www.example.com/abc
now http://www.example.com/default.aspx?article=abc
I have tried to use Global.asax to do this, and it works properly when I debug through it.
if (Request.RawUrl.Contains('abc')) { Response.RedirectLocation = '/default.aspx?article=abc'; Response.StatusCode = 301; Response.StatusDescription = 'Moved'; Response.End(); }
So http://localhost:1234/example/abc redirects properly, but (where 1234 is the port for the debugging server)
http://localhost/example/abc does not redirect, it gives me a 404.
Any ideas?
Additional info: If I go to http://localhost/example/abc/default.aspx then it redirects properly.
Well, if the port indicates you are using the built-in web server (the one that comes with VS), this probably works because that always routes requests through the ASP.NET framework.
Requests ending with /abc will not automatically route through the ASP.NET framework because IIS may not ‘know’ you want them to. You need to check your IIS settings to make sure such requests are routed to the aspnet_isapi.dll
EDIT: To accomplish this, you need to add a wildcard mapping:
I may be off on this, but if I am, hopefully someone will correct me. 🙂