Updating .net 4.0 machine.config seems to have no effect
I'm feeling stupid.
I've just created my first ASP.net 4.0 site after working my way though over the years from 1.1 upwards. We have several settings at the machine.config level that I need to migrate to the new 4.0 machine.confi开发者_StackOverflow社区g. I though I had be adding the required connection strings to the connection string section of the following two files:
- C:\Windows\Microsoft.NET\Framework64\v4.0.30319\machine.config
- C:\Windows\Microsoft.NET\Framework\v4.0.30319\machine.config
When I created a new website in IIS and assigned it to the ASP.net 4.0 Application pool I only get the default LocalSqlServer connection string. I tried editing the name of this in the two files above to indicate which file it was in, but there was no change.
Are there machine.config files in other locations I should be looking at?
Due to the wonders of microsoft putting the machine.config a few location the locations I actually wanted was:
C:\Windows\Microsoft.NET\Framework64\v4.0.3031\CONFIG\machine.config
C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG\machine.config
I had the same issue. I did't realize that my ConfigurationManager.ConnectionStrings["ConnectionNameWhateverItIs"].ConnectionString was looking at the Framework64 location. You can put the following line in your code to get location of the Machine Config file being used:
string connString = ConfigurationManager.OpenMachineConfiguration().ConnectionStrings.CurrentConfiguration.FilePath;
精彩评论