Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict asmx web services to be SSL Only

Tags:

asmx

I've got an ASMX web service that works great through an SSL conection, but I would like to make these web services inaccessible without SSL.

In web forms, I would just use the following code:

if (!Request.IsSecureConnection) Response.Redirect ("SomeOtherPage.aspx");

I know that WCF promises to be better in every way, but it's a real PITA to get something simple done with a tool as complicated as WCF.

like image 375
John Hoge Avatar asked Oct 14 '25 16:10

John Hoge


2 Answers

I have some other stuff on my site that is open to the public, so I chose not to take the IIS route. I did find a simple way in the asmx service to take care of the problem:

if (!this.Context.Request.IsSecureConnection)
    return null;
like image 152
John Hoge Avatar answered Oct 18 '25 03:10

John Hoge


Easy. Make a website in IIS that is only SSL and put this page in it. Don't allow non-SSL connections to this website

like image 34
Hogan Avatar answered Oct 18 '25 04:10

Hogan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!