Thursday, 11 August 2016

Asp Net Core MVC Change Folder Name And Now The Site Wont Run Anymore

So, you created a nice new project and realise that you spelt something wrong in the folder structure, something like the example below.

C:\Git\XmlXsltValidator

When is should have been...


C:\Git\XmlXsdValidator

Now this should be a simple thing of renaming the folder, updating whatever source control you use and its back to work again.

Unfortunately it's not, when I first did this by creating new project in Visual Studio 2015, corrected the folder name and then tried to run the project again I got a error dialog appear directing me to where the error was logged. 

A snippet of the error logged is below.
HTTP Error 500.19 - Internal Server Error
Config Error   Cannot read configuration file
Config File   \\?\C:\Git\XmlXsltValidator\src\XmlXsltValidator\web.config

To fix this I opened up the applicationhost.config, following the path described above, and then scrolled down to the system.applicationHost\sites node and noticed that were three sites which one was pointing to the old folder location. I removed this element, closed and reopened the solution and it was working again.

Incorrect XML
<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="XmlXsltValidator" id="2">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="C:\Git\XmlXsltValidator\src\XmlXsltValidator" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:61097:localhost" />
                </bindings>
            </site>
            <site name="XmlXsdValidator" id="3">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="C:\Git\XmlXsdValidator\src\XmlXsdValidator" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:61097:localhost" />
                </bindings>
            </site>



Correct XML

<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="XmlXsdValidator" id="2">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="C:\Git\XmlXsdValidator\src\XmlXsdValidator" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:61097:localhost" />
                </bindings>
            </site>

No comments:

Post a Comment