What happens when I edit web.config?

2019-01-06 10:52发布

问题:

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?

回答1:

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.



回答2:

  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


回答3:

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.



回答4:

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.



回答5:

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 poll will not be affected. Also it will clear the sessions(in-proc) and memory cache.



回答6:

If you have any thoughts of editing the web config, please look into the SPWebConfigModification class.