【问题标题】:Generating https action url for the form为表单生成 https 操作 url
【发布时间】:2014-09-28 05:57:37
【问题描述】:

我需要为表单的action 生成一个https URL。它应该在所有服务器、live、stage 和 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,这是不正确的。

【问题讨论】:

  • @Dan,你尝试过 HTTPs URL 重写,贴在下面吗?

标签: c# asp.net-mvc asp.net-mvc-4


【解决方案1】:

您是否尝试过 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

【讨论】:

    猜你喜欢
    • 2012-10-27
    • 1970-01-01
    • 2016-08-06
    • 2011-06-07
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多