我有点困惑,但在我的本地 IIS Express
上使用 T4MVC
呈现的 URL 在 URL 中包含 HTTPS。在我们的登台服务器上,正在呈现的 URL 包含 HTTP,但使用的是与下面相同的代码吗?有谁知道为什么吗?
<a href="#" data-bind="attr: { href: '@Url.GetSearchResultsUrl(MVC.ManageArea.DistrictAdmins.DistrictAdmin())&id=' + Id }">View</a>
public static string GetSearchResultsUrl(this UrlHelper urlHelper, ActionResult actionResult)
{
return urlHelper.ActionAbsolute(actionResult.AddRouteValue(Config.ViewData.SearchResults, true));
}
public static string ActionAbsolute(this UrlHelper urlHelper, ActionResult result) {
return string.Format("{0}{1}",urlHelper.RequestContext.HttpContext.Request.Url.GetLeftPart(UriPartial.Authority),
urlHelper.RouteUrl(result.GetRouteValueDictionary()));
更新
我刚刚发现 F5 负载平衡器正在使用 302 重定向从 http 重定向到 https。
最佳答案
最近有一些自动使用 https 的更改,但只有在您使用 [RequireHttps] 属性时才会发生这种情况。你知道你是否在使用它吗?
参见 change log了解详情。这是在 2.8.0/2.8.1 中添加的。
在 t4mvc.tt 中搜索 'ActionUrlHttps' 以查看相关代码。
关于asp.net-mvc-3 - T4MVC 和 HTTPS 未显示在 URL 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11249614/