Reputation: 2799
I'm having a puzzling problem with my web.config
file on Visual Studio 2015. I open the project, open the web.config
file and update a connection string to point to a different database source. I save the change and then close the web.config
file. If I open back up the web.config
file, the updates that I made are still there. But after I do a build, if I open the web.config
file my update has reverted to what was there previously. Any ideas why?
Upvotes: 6
Views: 5393
Reputation: 167
Is there a Config folder in your one of your project files?
The app I work on has 66 projects in the solution, and I had to track it down to find out why my changes weren't being implemented.
Upvotes: 0
Reputation: 187
You may have 'Web.Debug.config' or 'Web.Release.config' file in the project folder. In my case, I updated the database configuration value in 'Web.Debug.config' file when using debug mode then solved the issue.
Upvotes: 3
Reputation: 79
Try removing folder "obj" in the project's directory then rebuild the project.
Folder location:
$(ProjectDir)obj
Upvotes: -1
Reputation: 2062
Not sure if this applies to your case, but there is an "applicationhost.config" file in the "\YourAppName\.vs\config" folder that should be off the root of your project. Make sure all the links there are pointing to the current solution.
This just happened to me because I made a copy of an existing project to a new location and modified it. I came back after successful builds suddenly and ALL my web.config settings reverted to the original copy. Every node in the "web.config" matched to a "T". I edited any references from the old location to the new and hopefully this will no longer be an issue. This file apparently is not included in the search as it didn't come up when I looked for the old path within my project. Make sure you do a search for the old path also, just to be sure that it is not going to be an issue.
Upvotes: 0
Reputation: 435
I had the same issue. Turns out there was a modification to the default setup in my .csproj file...
<Target Name="BeforeBuild">
<TransformXml Source="Web.Template.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
</Target>
This generates the web.config file at Build time based on Web.debug.config, Web.release.config, etc.
As described in this article: http://www.kongsli.net/2012/01/13/enabling-web-transforms-when-debugging-asp-net-apps/
Upvotes: 4