Thursday 9 May 2013

Way in asp.net c# to force https for an entire 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);
   }
}


That would go in the global.asax.cs

No comments:

Post a Comment

Get all non-clustered indexes

DECLARE cIX CURSOR FOR     SELECT OBJECT_NAME(SI.Object_ID), SI.Object_ID, SI.Name, SI.Index_ID         FROM Sys.Indexes SI             ...