Code2night
  • Home
  • Guest Posts
  • Tutorial
  • Languages
    • Angular
    • C
    • C#
    • HTML/CSS
    • Java
    • JavaScript
    • Node.js
    • Python
    • React
    • SQL Server
    • TypeScript
  • Post Blog
  • Tools
    • JSON Beautifier
    • HTML Beautifier
    • XML Beautifier
    • CSS Beautifier
    • JS Beautifier
    • PDF Editor
    • Word Counter
    • Base64 Encode/Decode
    • Diff Checker
    • JSON to CSV
    • Password Generator
  • Register
  • Login
  1. Home
  2. Blogpost

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

Date- Apr 26,2022

10964

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.

S
Shubham Batra
Programming author at Code2Night โ€” sharing tutorials on ASP.NET, C#, and more.
View all posts โ†’

Related Articles

How to refund payment using Paypal in Asp.Net MVC
Jan 30, 2024
Integrate Stripe Payment Gateway In ASP.NET Core 8.0
Nov 23, 2023
How to get fcm server key
Nov 23, 2023
How to Convert Text to Speech in Asp.Net
Nov 06, 2023

Comments

Tags

AspNet
C#
programming
AspNet MVC
c programming
AspNet Core
C
software development
tutorial
MVC
memory management
Paypal
coding
coding best practices
data structures
programming tutorial
tutorials
object oriented programming
Slick Slider
StripeNet
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 | 1760
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
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blogs
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
Free Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Diff Checker
  • Base64 Encode/Decode
  • Word Counter
By Language
  • Angular
  • C
  • C#
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • React
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ยท  Terms
Translate Page