正在为表单生成https操作url

本文关键字:https 操作 url 表单 | 更新日期: 2023-09-27 18:24:59

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

正在为表单生成https操作url

您尝试过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.aspxhttp://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-moduleASP.NET-将所有https请求重写为http