Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Url.Action not including port number

I have a partial view which is displayed on a non-HTTPS page, but POSTS to a controller that requires SSL. The form definition is this:

        <form id="authForm"
          method="post"
          action="@Url.Action("authenticate", "auth", new {}, "https")">

The problem I'm having is that, within Visual Studio and when debugging, the host and port are localhost:64043. However, the Url.Action call above doesn't put the port number in, meaning the browser directs to my IIS installation. Do I have to add something else, or override this method? I want my application to be location agnostic.

Thanks in advance!

like image 537
Moo-Juice Avatar asked Jul 17 '11 10:07

Moo-Juice


1 Answers

You could include it like this:

@Url.Action(
    "authenticate", 
    "auth", 
    null, 
    "https", 
    Request.Url.Host + ":" + Request.Url.Port
)

Of course this means that your local web server must support SSL which is not the case with Cassini. You could use IIS Express for this to work.

like image 82
Darin Dimitrov Avatar answered Sep 29 '22 13:09

Darin Dimitrov