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

In prod, my site (mvc5) is hosted at https://company.no/myApp/

, where myApp is an application in IIS.

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

Since this calls for some truble with server relative routes, I would like to debug my on http://localhost:54307/myApp

.

Here's what I've tried:

  • Setting the project url on the property pages http://localhost:54307/myApp

    and clicking Create virtual directory
  • Tried overriding app root with or without myApp url.
  • Tried modifying applicationhost.config. Currently my setup 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 a page from the myApp folder, I get a 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

      

This means the web.config is loaded twice. Any idea what I am doing wrong?

Thanks for any help

Larsi

+3


source to share


1 answer


I have heard that IIS Express has problems with server relative paths. You can set this up with a few steps that do not involve manually editing your applicationhost.config. I try not to manually edit the applicationhost.config file, it causes more problems than it solves. I would remove the website from my local IIS to clear all these things, then follow these steps:



  • right click the web project and select properties.
  • Click "Menu"
  • change the dropdown to local IIS and enter the url you want the application to resolve and then click create virtual directory, save the file and build.
  • web tab
  • You can still debug without a port number, the debugger will just attach to this new website in your local IIS instance if you have the debugger option checked in the web tab.
  • open your local IIS and do any other configurations needed to run your application (authentication, application pools, etc.).
  • open your browser and go to http://localhost/YourAppName

  • since this is a website regarding your local iis, you can hit it anytime in your browser without having to launch Visual Studio.
+1


source







All Articles