Hello everyone, I am going to share the code sample for redirect http to https ASP.Net MVC projects using the different types of techniques. The techniques types as given belows. Types 1: You can add the below code in Global.asax.cs for redirect http to https. protected void Application_BeginRequest( Object sender, EventArgs e) { var httpRequest = HttpContext .Current.Request; if (httpRequest.IsSecureConnection.Equals( false ) && httpRequest.IsLocal.Equals( false )) { Response.Redirect( " https ://" + Request.ServerVariables[ "HTTP_HOST" ] + httpRequest.RawUrl); } } OR Types 2: You can add the below code in Global.asax.cs for redirect http to https. protected void Application_BeginRequest( Object sender, EventArgs e) { switch (Request.Url.Scheme) { ...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers