How to Auto Redirect from HTTP To HTTPS IN Asp.Net using Web Config | Code2night.com
Code2night
  • Home
  • Blogs
  • Guest Posts
  • Tutorial
  • Post Blog
  • Register
  • Login
  1. Home
  2. Blogpost

How to Auto Redirect from HTTP To HTTPS IN Asp.Net using Web Config

Date- Apr 26,2022

7985

Web Config Auto Redirection

Auto Redirect from HTTP to HTTPS

So, for adding auto redirect in your Asp.net Web application we can use web config file. As changing in web config file is easier and effective.

So, for forcing auto redirect from http to https we have to add rewrite rules in our web config file.

These rules must be added in <System.WebServer> node , as showed below.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<system.webServer>
		<rewrite>
			<rules>
				<remove name="Http to Https" />
				<clear />
				<rule name="Redirect all requests to https" stopProcessing="true">
					<match url="(.*)" />
					<conditions logicalGrouping="MatchAll">
						<add input="{HTTPS}" pattern="off" ignoreCase="true" />
					</conditions>
					<action 

            type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" 

            redirectType="Permanent" appendQueryString="true" />
				</rule>
			</rules>
		</rewrite>
	</system.webServer>
</configuration>

After, adding this now save your web config and run the project. You will see your site is automatically redirected from http to https.

So this is how we can achieve auto redirect from http to https in  Asp.Net Web Application.

Comments

Tags

LinkedinLogin
LinkedinProfile
GetLinkedinProfile
C#
Aspnet
MVC
Linkedin
ITextSharp
Export to Pdf
AspNet Core
AspNet
View to Pdf in Aspnet
Model Validation In ASPNET Core MVC 60
Model Validation
Model Validation In ASPNET Core MVC
Model Validation In ASPNET
Image Compression in AspNet
Compress Image in c#
AspNet MVC
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1190
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp Join Us On Facebook

Welcome To Code2night, A common place for sharing your programming knowledge,Blogs and Videos

  • Panipat
  • info@Code2night.com

Links

  • Home
  • Blogs
  • Tutorial
  • Post Blog

Popular Tags

Copyright © 2025 by Code2night. All Rights Reserved

  • Home
  • Blog
  • Login
  • SignUp
  • Contact
  • Terms & Conditions
  • Refund Policy
  • About Us
  • Privacy Policy
  • Json Beautifier
  • Guest Posts