Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在构建一个MVC4助手,并想从HtmlHelper课堂上找出请求是否来自安全(https)连接(http)?
MVC4
HtmlHelper
https
http
像这样的东西,假设 helper 是类型HtmlHelper<T>或HtmlHelper
HtmlHelper<T>
helper.ViewContext.RequestContext.HttpContext.Request.IsSecureConnection;
或者也许是捷径
helper.ViewContext.HttpContext.Request.IsSecureConnection;