ASP.NET web.config: configSource vs. file attributes

Within an web.config-file in an ASP.NET-application some sections of config, like appSettings and connectionStrings, supports the attributes file and configSource. What is the difference between using the file-attribute and the configSource-attribute? When should you use which attribute and can you use both? <?xml version=”1.0″?> <configuration> <appSettings file=”AppSettings.config”> </appSettings> <connectionStrings configSource=”ConnectionStrings.config”> </connectionStrings> <!– … –> </configuration> … Read more

Using different Web.config in development and production environment

I need to use different database connection string and SMTP server address in my ASP.NET application depending on it is run in development or production environment. The application reads settings from Web.config file via WebConfigurationManager.AppSettings property. I use Build/Publish command to deploy the application to production server via FTP and then manually replace remote Web.config … Read more

Difference between and ?

Every time I have to add a handler or module for ASP.NET with IIS7, the instructions always tell me to incorporate it into two sections: system.web and system.webserver. <system.web> <httpHandlers> </httpHandlers> <httpModules> </httpModules> </system.web> And this: <system.webServer> <modules> </modules> <handlers> </handlers> </system.webServer> What is the difference between these two sections? In addition, if I don’t … Read more

Error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level

It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level. The top line in all of my aspx pages in my /portal/ directory has this error message, and I know it’s a common one. I have googled this error message to no end, and I see a lot of posts telling … Read more

How can I add an ampersand for a value in a app config file value

I’ve got a C# program with values in a config file. What I want is to store ampersands for an url value like… <appSettings> <add key=”myurl” value=””/> </appSettings> But I get errors building my site. The ampersand is not allowed. I’ve tried various forms of escaping the ampersands to no avail. Anyone know of the … Read more

Specified argument was out of the range of valid values. Parameter name: site

I am getting this Kind of Error like:: Specified argument was out of the range of valid values.Parameter name: site while Debugging any of my Project. I have also tried after Reinstalling My Visual Studio 2012. But again the same kind of problem I am getting while Debugging. My System’s Configurations are : Windows 8 … Read more

How to change the value of attribute in appSettings section with Web.config transformation

Is it possible to transform the following Web.config appSettings file: <appSettings> <add key=”developmentModeUserId” value=”00297022″ /> <add key=”developmentMode” value=”true” /> /* other settings here that should stay */ </appSettings> into something like this: <appSettings> <add key=”developmentMode” value=”false” /> /* other settings here that should stay */ </appSettings> So, I need to remove the key developmentModeUserId, and … Read more