I am using ASP.NET 2.0 C#. I want to redirect all request for my web app with "www" to without "www"
www.example.com to example.com
Or
example.com to www.example.com
Stackoverflow.com is already doing this, I know there is a premade mechanism in PHP (.htaccess) file. But how to do it in asp.net ?
Thanks
I've gone with the following solution in the past when I've not been able to modify IIS settings.
Either in an HTTPModule (probably cleanest), or global.asax.cs in Application_BeginRequest or in some BasePage type event, such as OnInit I perform a check against the requested url, with a known string I wish to be using:
Then register the class in your web.config:
This method works quite well for us.