Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to ensure that an ASP.NET application is (only) running on the HTTPS protocol?

I'm wondering if there is a way to ensure that an ASP.NET application can only be run using the HTTPS protocol

I'm fine with any code (defensive programming measure perhaps?) that can do the trick, or possibly some IIS/web server setting that can get the job done.

like image 673
Joseph Avatar asked May 27 '09 17:05

Joseph


3 Answers

IIS will definitely allow you to require HTTPS. The instructions are here.

Edit: I had to go dig for it, but there's also Request.IsSecureConnection for defensive programming.

like image 184
Randolpho Avatar answered Oct 12 '22 02:10

Randolpho


The only problem with enforcing the SSL on the IIS level is that the user receives an ugly 403.4 page error

"The page must be viewed over a secure channel"

To make the transition seamless, you could redirect the user to the secure site using the Request.IsSecureConnection if they do not generate the request over SSL.

like image 32
Michael Kniskern Avatar answered Oct 12 '22 02:10

Michael Kniskern


There is a nice article that has some good information and a helper utility class on this subject over at leastprivilege.com

like image 1
slolife Avatar answered Oct 12 '22 04:10

slolife