JCTLK
JCTLK

Reputation: 2165

301 permanent redirect in asp.net 2005

I am having an asp.net application which had being developed using asp.net 2.0 (VS 2005). In that app I am having a method to rewrite Urls. I need to redirect certain urls permanently.

I have used following code to do so. (Inside my ApplicationBeginrequest method)

string newPath301 = "www.abcd.com/WebShop/Product.aspx?id=" + id + extraParameters;
app.Response.Clear();
app.Response.ClearHeaders();                            
app.Response.Status = "301 Moved Permanently";
app.Response.AddHeader("Location", newPath301);

But what actually happens is the response goes to a location something like

Current Location + "www.abcd.com/WebShop/Product.aspx?id=" + id + extraParameters

I really don't have an idea about this. Want to know whether I have done it improperly. If any more info needed please mention.

Thank You

Upvotes: 0

Views: 177

Answers (1)

Jamie Dixon
Jamie Dixon

Reputation: 53991

Add http to the front of the new URL.

Without the protocol, aspnet thinks you're trying to redirect to a path on the current domain.

Upvotes: 1

Related Questions