0

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>
SilverFish
  • 1,014
  • 6
  • 28
  • 65
  • 1
    "but I cannot run locally" -- what happens when you attempt to run it locally? Any error messages? – Steven V Jul 25 '17 at 20:19
  • "HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid." Under detailed Error Information it gives "Error Code 0x80070021 Config Error Configuration section not allowed to be set below application" – SilverFish Jul 25 '17 at 21:15
  • when I turn on dev tools I get: Failed to load resource: the server responded with a status of 500 (Internal Server Error) default.aspx – SilverFish Jul 25 '17 at 21:16
  • Under error details I also get Config Error Configuration section not allowed to be set below application Config File \\?\C:\Projects\Jupiter\Databases\DART_40\DART\web.config whereas the web.config for the project is located at C:\Projects\Jupiter\Databases\DART_40\DART\MyReporting\web.config where would I need to set that? – SilverFish Jul 25 '17 at 21:41
  • If that error comes from a web.config, post the content of that file. – Lex Li Jul 25 '17 at 22:44

1 Answers1

0

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!

RansomV
  • 41
  • 1
  • 7