Visual Studio 2015 IIS Express issue applicationhost.config

409 Views Asked by At

I have converted VS 2010 web application project to VS 2015. The published application to development server looks fine, but I cannot run locally. I see various posts to fix applicationhost.config file but I do not seem to find the issue. Please suggest if you can see what to fix. This is from applicationhost.config under my project directory: ~\MyReporting.vs\config

   <sites>
        <site name="WebSite1" id="1" serverAutoStart="true">
            <application path="/">
                <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation=":8080:localhost" />
            </bindings>
        </site>
        <site name="MyReporting-Site" id="2">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="C:\Users\<User>\Documents\My Web Sites\MyReporting-Site3" />
                <virtualDirectory path="/DART" physicalPath="C:\Projects\Jupiter\Databases\DART_40\DART" />
            </application>
            <application path="/DART/MyReporting" applicationPool="Clr4ClassicAppPool">
                <virtualDirectory path="/" physicalPath="C:\Projects\Jupiter\Databases\DART_40\DART\MyReporting" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:17588:localhost" />
            </bindings>
        </site>
        <siteDefaults>
            <logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
            <traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
        </siteDefaults>
        <applicationDefaults applicationPool="Clr4IntegratedAppPool" />
        <virtualDirectoryDefaults allowSubDirConfig="true" />
    </sites>
1

There are 1 best solutions below

0
On

I created a WebApp project in VS 2015 that I wanted to debug locally.

Of course when I built, the results went into $(ProjectDir)\bin, but VS would modify the applicationhost.config to run in the root $(ProjectDir). As a result, I would get 404 errors for my generated files. I tried several suggestions, such as:

  • Using <UseGlobalApplicationHostFile>
    But that just changed which applicationhost.config was modified.
  • Using 'Override application root URL'
    But contrary to posts I found, it did update the physicalPath.
  • Modifying several properties under <WebProjectProperties>
    But I couldn't find anything that would work.

I finally found a work-around that is good enough for me:

  1. Right-click on the Solution and select Add -> Existing Web Site...
  2. Select your Project's Output folder.
  3. Right-click on the Solution and select Project Dependencies...
  4. For "Projects:" select the Web App Project.
  5. Turn on the checkbox for your Web Project and click OK.
  6. Right-click on the new Web Project and select "Set as StartUp Project".

Now, when you Run your solution, it will launch the code in the Output folder.
Unfortunately, when you try to debug, you have to set your breakpoints in the Web Project files, then modifications have to be done in the Web App Project files, but that is the best solution I have been able to come up with.

NOTE:
One time I did this, it named my new Web Project the same name as my Web App Project. As such, when trying to set dependencies I couldn't tell which was which. To deal with this:

  • Before step 3 above, temporarily rename your Web App Project
    (I couldn't figure out how to rename my Web Project.)
  • After step 6:
    1. Close the Solution
    2. Manually rename the .csproj file back to the original name.
    3. In a text editor, open your .sln file, find the temp name and change it back.
      For example, change:
      Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyTempName", "folder\MyTempName.csproj"
      to:
      Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyOriginalName", "folder\MyOriginalName.csproj"
    4. Reopen the Solution.

Good Luck!