[英]"The requested resource can only be accessed via SSL." on Azure's app with Only HTTPS redirect activated?
I've a ASP.NET MVC (.NET 4.6.2) app run within Azure.我有一个在 Azure 中运行的 ASP.NET MVC (.NET 4.6.2) 应用程序。 I've configured the DNS and the Only HTTPS redirect.
我已经配置了 DNS 和 Only HTTPS 重定向。
If I type http://myapp.mydomain.com on browser, it correctly redirect to https://myapp.mydomain.com如果我在浏览器上输入http://myapp.mydomain.com ,它会正确重定向到https://myapp.mydomain.com
BUT, sometimes I got some error from Global's Application_Error() method of MVC, which say "The requested resource can only be accessed via SSL.".但是,有时我从 MVC 的 Global 的 Application_Error() 方法中得到一些错误,它说“请求的资源只能通过 SSL 访问。”。 And the SourceURL param is http://myapp.mydomain.com
而 SourceURL 参数是http://myapp.mydomain.com
How can it be if the HTTPS redirect is activated?如果HTTPS重定向被激活怎么办? How can I simulate this event?
我怎样才能模拟这个事件?
The RequireHttps
attribute does automatically attempt to redirect to https://your-url
. RequireHttps
属性会自动尝试重定向到https://your-url
。
So,所以,
Add this to your Controller methods and it behaves as expected.将此添加到您的 Controller 方法中,它会按预期运行。
If you redirect to the Index action on the controller from a HTTPS protocol, it will redirect to HTTP .如果您从HTTPS协议重定向到控制器上的 Index 操作,它将重定向到HTTP 。
It only allows HTTP access to the Index ActionResult.它只允许HTTP 访问索引 ActionResult。
[RequireHttp]
public ActionResult Index() {
return View();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.