What happens when I edit web.config?

asp.netSharepointIis 6

asp.net Problem Overview


I need to edit the web.config file on a live Sharepoint environment, but I'm unsure what will happen if I do (I want to output custom errors).

Will this cause the IIS6 worker process to recycle?

Will active users lose their session state because of this?

Or can I safely edit the file?

asp.net Solutions


Solution 1 - asp.net

The application pool will restart and session state will be lost. Imagine each ASP.NET application (as defined in IIS) is a program on the desktop. Saving web.config will do something similar to closing the program and reopening it.

Solution 2 - asp.net

  1. Yes. It will be recycled.
  2. Yes. They will lose their session.
  3. Yes. You can safely edit the file. I suggest you to read this MSDN article : Working with web.config Files in Windows SharePoint Services

Solution 3 - asp.net

Also if Session state is configured as out-of-process (database or service) then recycling the app pool won't lose any session state. This is as true for Sharepoint as it is for vanilla ASP.Net.

Solution 4 - asp.net

When you edit the web.config, It will restart the AppDomain (NOT AppPool) of that web application and clears the all occupied resources and memory. So other web applications running under that App Pool will not be affected. Also it will clear the sessions (in-proc) and memory cache.

Solution 5 - asp.net

As already mentioned by some people: the application pool of the site in IIS will restart (this typically takes a couple of seconds). As a result the next page request(s) will be slower (since nothing will be cached anymore). Also the session state of the users will be lost; BUT in WSS session state is not used by default, in MOSS it is used by InfoPath Form Services. So it could be that you don't have big issues related to losing session state.

On the other side; to overcome those issues: what is typically done is to create a SharePoint Solution (WSP) that deploys and starts a Timer Job to make the changes to the web.config from code (using the SPWebConfigModification class of the Object Model). The nice thing is that you can schedule the execution of the change, so your users won't notice it.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionwillemView Question on Stackoverflow
Solution 1 - asp.netDan GoldsteinView Answer on Stackoverflow
Solution 2 - asp.netPascal ParadisView Answer on Stackoverflow
Solution 3 - asp.netpiers7View Answer on Stackoverflow
Solution 4 - asp.netJay ShahView Answer on Stackoverflow
Solution 5 - asp.netJan TielensView Answer on Stackoverflow