3

Using the [RequireHttps] port in an ASP.NET MVC application causes a redirect to HTTPS on port 443 if the user attempts to access the application over HTTP.

However, in IIS Express, the application will probably not running on port 443. It will, instead, be running on something like port 44301.

I've found various tips for replacing RequireHttpsAttribute with an implementation that takes the alternative port number as a parameter, or reads it from Web.config.

This is clunky, because it requires configuration in more than one place.

Is there any way to do this -- programmatically -- in a generic fashion?

Without trying to pre-empt the answers, some options occur to me:

  1. Is there any way to discover the bindings being used by the instance of IIS or IIS Express that's hosting my app?
  2. Is there any way to read applicationHost.config for the current IIS / IIS Express host?
Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380
  • Did you seen this: http://stackoverflow.com/questions/3690901/iis-express-defaulting-to-port-44300-for-https-when-enabling-ssl?rq=1 – Kev Jul 23 '13 at 15:11
  • Yeah. I don't want to change IIS Express to use port 443, because I have more than one HTTPS application running in IIS Express. I also already have IIS using port 443. – Roger Lipscombe Jul 23 '13 at 16:15

1 Answers1

0

You can check currently used bindings (of IIS/IIS Express) by running following command

"netsh http show servicestate view=requestq"

You can find applicationhost.config file of IIS Express in %userprofile%\documents\iisexpress\config folder.

vikomall
  • 17,379
  • 6
  • 49
  • 39