VS 2013 / IIS Express - serve site from localhost:port/myapp instead of localhost:port

3

In prod my site (mvc5) is hosted on https://company.no/myApp/ where myApp is an Application on IIS.

In dev my site is hosted on IIS Express on http://localhost:54307/

As this causes some truble with server relative paths I would like to also do my debugging on http://localhost:54307/myApp.

This is what I've tried:

  • Setting project url in property pages to http://localhost:54307/myApp and clicking Create Virtual directory
  • Tried the override application root with or without the myApp url.
  • Tried modify the applicationhost.config. Currently my setting looks like this:

      <site name="MyApp.Web-Site" id="38">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="C:\Projects\OP\MyApp\Main\src\MyApp.Web" />
            </application>
            <application path="/MyApp" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="C:\Projects\OP\MyApp\Main\src\MyApp.Web" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:54307:localhost" />
                <binding protocol="https" bindingInformation="*:44307:localhost" />
            </bindings>
        </site>
    

When I try to open page from the myApp folder I get the follownig error:

 Module    IIS Web Core
 Notification      BeginRequest
 Handler       Not yet determined
 Error Code    0x800700b7
 Config Error      Cannot add duplicate collection entry of type 'add' with unique key attribute      'name' set to 'WSFederationAuthenticationModule'
 Config File       \\?\C:\Projects\OP\MyApp\Main\src\MyApp.Web\web.config
 Requested URL     http://localhost:54307/MyApp
 Physical Path     C:\Projects\OP\MyApp\Main\src\MyApp.Web

That indicates web.config loaded twice. Any idea what I'm doing wrong?

Thanks for any help

Larsi

asp.net
asp.net-mvc
iis
visual-studio-2013
iis-express
asked on Stack Overflow Sep 17, 2014 by Larsi

1 Answer

1

I hear you with IIS Express causing problems with server relative paths. You can set this up with a couple steps that don't include manually editing your applicationhost.config. I try to avoid editing the applicationhost.config manually, it seems to cause more problems than it solves. I would remove the website from your local IIS to clear out any of that stuff and then do the steps below:

  • right-click on your web project and select properties.
  • Click on the "Web" menu
  • change the dropdown to Local IIS and enter the URL you would like the app to resolve to then click create virtual directory, save the file and build.
  • web tab
  • You can still debug without the port number, the debugger will just attach to this new website in your local IIS instance as long as you have a debugger option checked on the web tab.
  • open your local IIS and make any other configurations that are required for your app to run (Authentication, Application Pools, etc.).
  • open your browser and navigate to http://localhost/YourAppName
  • since this is a website as far as your local iis is concerned, you can hit it anytime in a browser without needed Visual Studio running.
answered on Stack Overflow Sep 17, 2014 by Adrian

User contributions licensed under CC BY-SA 3.0