简体   繁体   English

“请求的资源只能通过 SSL 访问。” 在仅激活 HTTPS 重定向的 Azure 应用程序上?

[英]"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.

相关问题 AppHarbor错误只能通过SSL访问请求的资源 - Error on AppHarbor The requested resource can only be accessed via SSL 仅适用于Azure App Service https-带有授权属性的错误重定向 - Azure App Service https only - wrong redirect with authorize attribute redirect_uri_mismatch与AppHarbor上仅使用https的应用程序 - redirect_uri_mismatch with https-only app on AppHarbor 仅在SSL请求上重定向到另一个域MVC - Redirect ONLY on SSL request to another domain MVC ModelState如果只在HttpPost中创建,如何在HttpPut中访问? - How can ModelState be accessed in HttpPut if it is only created in HttpPost? 使 Azure 门户上的 Web 应用程序仅在一周内可用几个小时 - Make the Web App on Azure portal only Available few hours in a Week Azure-是否可以仅通过登录访问用户的订阅/资源? - Azure - Is it possible to access a user's subscriptions/resources with only a log-in? 登录后Azure网站丢失安全的SSL / Https - Azure website losing secure SSL/Https after log in 从 Http 到 Https 的重定向仅在安装了应用程序的 iis 服务器浏览器内部有效 - Redirection from Http to Https works only internally on iis server browser where is app installed 404仅重定向页面而不是图像 - 404 redirect for pages only not images
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM