Use SSL in code in ashx handler

I have a website that contains several ashx handlers, for a couple of handlers that I want to reject non-SSL requests. Is there a way I can do this in code?

+3
source share
3 answers

If you have to do this programmatically, then as I did in the past, this is to check the URL and find "https" in it. Forwarding if you do not see this. However, Request.IsSecureConnection should be preferred. You may need to add additional logic to handle the return address.

+5
source

I think the correct way is to check the Request.IsSecureConnection property and redirect or throw if it is false

+3

Try using System.Web.HttpContext.Current.Request.IsSecureConnection to check if they connect securely and then complete any failures you would like after that (returning an error message or what is needed for your business).

+2
source

Source: https://habr.com/ru/post/1696833/


All Articles