tags:

views:

41

answers:

2

I've inherited a pile of code for a web app which contains oodles of hard-coded paths. I've been tasked with trying to get it to run using https://.

Other than detecting "https://" in the URL is there a more inband way to detect that the current context is https?

Looking for something like:

System.Web.HttpContext.Current.Request.Url.Protocol.ToString()

+2  A: 

You can use HttpContext.Current.Request.IsSecureConnection

Brandon
+2  A: 

The direct answer to your request for something like System.Web.HttpContext.Current.Request.Url.Protocol.ToString() is System.Web.HttpContext.Current.Request.Url.Scheme, though as Brandon says, in his answerHttpContext.Current.Request.IsSecureConnection is the way to detect use of https as a boolean and likely more appropriate to the problem you give in your question.

Jon Hanna