从HttpContext的HTTPS检测在​​.net中?HttpContext、HTTPS、net

2023-09-03 02:22:51 作者:撩人妖精

我继承了一堆$ C $下一个web应用程序,其中包含的硬codeD路径不减当年。我一直在负责试图让它使用https运行://。

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://.

除了检测https://开头?在URL中是否有更多的带内方法来检测当前上下文为https

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

寻找这样的:

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

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

推荐答案

您可以使用 HttpContext.Current.Request.IsSecureConnection