I'm using the following to force https on my site:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (HttpContext.Current.Request.IsSecureConnection.Equals(false) && HttpContext.Current.Request.IsLocal.Equals(false))
{
Response.Redirect("https://" + Request.ServerVariables["HTTP_HOST"]
+ HttpContext.Current.Request.RawUrl);
}
}
Is there anything I can add to this code that will also strip "www" from the url as well? That way if a user types "http://www.URL.net" it will automatically go to "https://URL.net".
**note: I'm using IIS6 and can't upgrade to IIS7.