I have user global.asax and I have write this code in my ASP.NET application :
<%@ Application CodeBehind="Global.asax.cs" Language="C#" %>
<script RunAt="server">
public void Application_Start()
{
string str = Context.Request.Url.AbsoluteUri.Replace("http", "https");
Context.RewritePath(str);
}
</script>
but it gives me this :
"Request is not available in this context"
From http to https you need to make redirect.
The main reason the RewritePath is not working is because the http and https work on different ports. Also the Application Start is not the place to call this thinks. The BeginRequest is the one.
So if you like to change all the request automatically to https, use this code.
You can also use this module to make this switching automatically.