iis - Can I detect if SSL/https is enabled for an ASP.NET website from within the site's code? -


i'm working on cms can run either or without https enabled on webserver. i'd able detect whether https enabled or not, can act accordingly (for example, display https-related options administrator, , redirect https administrator logins).

i'm not looking request.issecureconnection because tells me if current request via https. want tell me whether current bindings site in iis include binding https @ same domain current request on. so, example, if current request http://example.com/ , not secure, want know whether https://example.com/ work can (for example) redirect user if log in administrator.

i've had no luck looking in system.web.configuration tell me bindings of current site, though.

my current workaround require administrator set appsetting in web.config if https enabled, i'd prefer if make automatic. having set same thing twice - once in iis , once in web.config - confusing.

the simplest way make https request site site , if succeeds know https supported. cache in static variable it's called once per app invocation.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -