我需要为表单的action
生成https网址。它应该适用于所有服务器,live,stage和localhost。
在localhost中:localhost:port/submiturl
- 此处无需https。
直播:https://domain.com/submiturl
在舞台上:https://stage.domain.com/submiturl
我不能将整个页面放在SSL下,但我特别需要放置表单的动作。
如何以编程方式执行此操作?
编辑:
我试过了action="@Url.Action("Action", "Controller", null, "https")"
但它在localhost中生成https://localhost/Controller/Action
,这是不正确的。
答案 0 :(得分:0)
您是否尝试过HTTP URL重写,如果从domain.com和stage.domain.com收到请求,您可以指定条件并编写代码以重定向到HTTPS。
以下是一些可能有用的链接。
http://blogs.msdn.com/b/sojesh/archive/2009/05/26/http-to-https-redirection-using-asp-net-http-module.aspx http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module ASP.NET - rewriting all https requests to http