none
How to get VS 2015 to stop updating the PhysicalPath property in applicationhost.config?

    Question

  • Visual Studio 2015 keeps overwriting my settings in applicationhost.config for a Web site project.

    It is changing this:

    <application path="/">
    <virtualDirectory path="/" physicalPath="C:\BlankDirectory" />
    </application>

    To this:

    <application path="/">
    <virtualDirectory path="/" physicalPath="C:\RootOfMyApplication" />
    </application>

    which is a problem since I have another application defined in this file with the same root and having two applications with the same root gives me compilation errors.

    Sunday, June 05, 2016 6:14 PM

All replies

  • Hi Mike,

    Could you share us more detailed information about this issue? How did you create your web site or edit the applicationhost.config?

    Is it similar to this issue posted by you here? Do you add new virtual directory?

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/d2a3d5e9-6d12-4224-b291-9f740662ffe8/how-to-get-vs-2015-web-site-to-behave-like-vs-2010-web-site-with-virtual-paths?forum=visualstudiogeneral#d2a3d5e9-6d12-4224-b291-9f740662ffe8

    Please share us the detailed steps about how to repro this issue, as you said that the "Please share us the detailed steps about how to repro this issue, as you said that the", whether your new project has the same name as your previous one, so they will change the "physicalPath" or others.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, June 07, 2016 7:31 AM
    Moderator
  • The web site was created back in Visual Studio 2005 using the traditional method. I don't see any GUI to edit the applicationhost.config file inside Visual Studio 2015 and all the Web site property fields are greyed out, so I am editing that file using NotePad++.

    This is not a virtual directory by rather an application that is not hosted in the root of the server.

    My application is not at http://localhost/, but rather http://localhost/appname/. I don't have any application at the root of the server. Visual Studio 2015 demands that the root have an application defined because if throws an error if I remove that entry in the config file. The suggestion on StackOverflow was to point the root at an empty directory, which works, up until Visual Studio overwrites that setting and points the root of the server at the same directory as the root of my application. This causes a failure due to double loading of the web.config file when two applications are both pointing at the same folder. I don't know why this setup causes double loading of Web.config, so that is another avenue of fixing the problem if that behavior can be stopped.

    To reproduce the issue:

    -create a Web site in Visual Studio 2010 with a virtual path of "appname."

    -If you test it the Web site opens to http://locahost/appname.

    -Open that same Web site in Visual Studio 2015 and the virtual path is gone. The Web site now opens in http://localhost/, which does not work if /appname/ is referenced throughout the application.

    -Hack the applicationhost.config file to reintroduce the appname application, which requires changing the root application to an empty directory. This fixes the problem.

    -Close Visual Studio 2015 and open it back up again. Visual Studio will have overwritten the fix made to applicationhost.config, thereby breaking the Web site.

    Tuesday, June 07, 2016 6:21 PM
  • Hi Mike,

    >>Open that same Web site in Visual Studio 2015 and the virtual path is gone. The Web site now opens in http://localhost/, which does not work if /appname/ is referenced throughout the application.

    I could repro this issue, it really has no the "virtual path" property in VS2015 now.

    >>Hack the applicationhost.config file to reintroduce the appname application, which requires changing the root application to an empty directory. This fixes the problem.

    Do you mean that change the physicalPath to be an empty directory like the following sample?

    <site name="WebSite1" id="1" serverAutoStart="true">
                    <application path="/">
                        <virtualDirectory path="/" physicalPath="" />
                    </application>
                    <bindings>
                        <binding protocol="http" bindingInformation=":8080:localhost" />
                    </bindings>
                </site>

    >>Close Visual Studio 2015 and open it back up again. Visual Studio will have overwritten the fix made to applicationhost.config, thereby breaking the Web site

    But if I run the web site again in VS2015, it still uses the previous url http://localhost/, and I got the same settings in the applicationhost.config.

    <site name="WebSite1" id="1" serverAutoStart="true">
                    <application path="/">
                        <virtualDirectory path="/" physicalPath="" />
                    </application>
                    <bindings>
                        <binding protocol="http" bindingInformation=":8080:localhost" />
                    </bindings>
                </site>

    Do I use the same steps as yours?

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 08, 2016 12:39 PM
    Moderator