Reputation: 3058
I need to configure a quick IIS redriect from "....sitename.com/login.html/" to "....sitename.com/login.html" without using isapi rewrite.
I have tried adding the redirect in Application_BeginRequest.
void Application_BeginRequest(object sender, EventArgs e)
{
//To Redirect Bad-Url (login.html/) which i subscribed to uConnect.intel.com
if (string.Compare(this.Request.Url.AbsolutePath, "login.html/", StringComparison.OrdinalIgnoreCase) != 0)
{
this.Response.Redirect("../login.html", true);
}
}
But it is not being hit and custom 404 error page is shown.
Could someone one help me if i can achieve this with some iis-property changes?
Upvotes: 0
Views: 1271
Reputation: 25834
you need to configure iis6 to let .net handle .html extensions. Normally iis just serves html pages without processing them server side, so your .net redirection code never gets invoked.
See this answer for instructions on configuration: IIS 6 executing html as aspx
Upvotes: 1
Reputation: 133403
Best solution is to use Microsoft URL Rewrite which can be downloaded from
http://www.iis.net/downloads/microsoft/url-rewrite
After installing
URL Rewrite option will appear in under IIS section in IIS 7.5
You can add rule to remove trailing slash
Upvotes: 1