0

I need to generate a https URL for the action of a form. It should function on all servers, live, stage, and localhost.

In localhost: localhost:port/submiturl - no need to https here.

In live: https://domain.com/submiturl

In stage: https://stage.domain.com/submiturl

I cannot put the whole page under SSL, but I specifically need to put the action of the form.

How can I do this programmatically?

Edit:

I've tried action="@Url.Action("Action", "Controller", null, "https")"

But it generates https://localhost/Controller/Action in localhost, which is not correct.

Dan
  • 11
  • 2

1 Answers1

0

Have you tried HTTP URL rewrite, you can specify condition and write code to redirect to HTTPS if request it is received from domain.com and stage.domain.com.

Following are some links that might be helpful.

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

Community
  • 1
  • 1
Arindam Nayak
  • 7,346
  • 4
  • 32
  • 48