Modify web.config on runtime - asp.net

If I modify an object on web.config that populates a combobox in a web application that is in a staging area or even production, do I need to restart the IIS or it detects that the web.config was changed?
Sorry for the silly question
Ty

Changes to configuration settings in Web.config files indirectly cause
the application domain to restart. This behavior occurs by design.
From MSDN

any change to the web.config will initiate a recycle of the application pool, you do not need to restart anything.

Related

Edit aspx page cause session lost

I am developing with VS2012 also it was same with VS2010. I working on a Web Application project. I have added a virtual application on IIS and set my project root folder as localhost/MyWebApp.
It often happens, when I do a simple page edit (on .aspx files) my site loses sessions. I am sure that no server side code is changed or no runat=server tag was affected.
How can I get rid of this?
Elaborating on David's comment:
File Change Notification
ASP.NET 2.0 depends on File Change Notifications (FCN) to see if the
application has been updated, and depending on the magnitude of change
the application pool will recycle. If you or your application are
adding and removing directories to the application folder, then you
will be restarting your application pool every time.
Altering the following files also causes an immediate restart of the
application pool:
web.config
machine.config
global.asax
Any file in the /bin directory or subfolders
Updating .aspx files, etc. causing a recompile eventually triggers a
restart of the application pool also. There is a property of the
compilation element under system.web called
numRecompilesBeforeAppRestart. The default value is 20, meaning that
after 20 recompiles the application pool will recycle.
Taken from: Losing ASP.NET Sessions - Why Application Pools recycle
Answer from Hans V:
When using the default SessionState Mode "InProc", you session will
be lost when the application pool recycles. Therer are many reasons
why this could happen, but also when you change aspx files:
ASP.NET depends on File Change Notifications (FCN) to see if the
application has been updated. Depending on the change the application
pool will recycle. If you or your application is adding and removing
directories to the application folder, you will be restarting your
application pool every time, so be careful with those temporary
files. Altering the following files will also trigger an immediate
restart of the application pool:
web.config
machine.config
global.asax
Anything in the bin directory or it's sub-directories
Updating the .aspx files, etc. causing a recompile will eventually
trigger a restart of the application pool as well. There is a
property of the compilation element under system.web that is called
numRecompilesBeforeAppRestart. The default value is 20. This means
that after 20 recompiles the application pool will recycle.
Answer reference

Automatically restarting IIS7

I want to know all possibilities that IIS7 application pool automatically restart.
Because I'm facing such situation and i have no idea about what should i looking for.
There are a lot of reasons that an IIS app pool may restart. The best resource I've found was a blog post ASP.NET Case Study: Lost session variables and appdomain recycles, by Tess Ferrandez that goes into detail on how to identify the issue and fix it. She lists the following reasons that an app domain will recycle:
An application domain will unload when any one of the following occurs:
Machine.Config, Web.Config or Global.asax are modified
The bin directory or its contents is modified
The number of re-compilations (aspx, ascx or asax) exceeds the limit specified by the setting in machine.config or web.config (by default this is set to 15)
The physical path of the virtual directory is modified
The CAS policy is modified
The web service is restarted (2.0 only)
Application Sub-Directories are deleted (see Todd’s blog http://blogs.msdn.com/toddca/archive/2006/07/17/668412.aspx for more
info)

Can an ASP.NET web app run without web.config

Can my asp.net web application run without a web.config?
For argument's sake lets say that I'm not connecting to a Database or explicitly reading any
configuration information .
I have tried it out and I'm able to run a web app successfully in VS 2008 without a web.config.
This brings me to the question as to how are authentication and session modes configured now ?
The machine.config and the root web.config files ( in the framework folder) do not have any authentication/session modes configured explicitly .
Any ideas ?
Thanks.
yes we can run asp.net application without web.config file,if u r not configure any settings in web.config file then it will take machine.config file for default configurtaons.This config file will automatically installed when your application getting executed.
Because all the configuration settings will be available under MACHINE.CONFIG file by default these settings will be applied to all asp.net applications.
You'd have to read the documentation to see the defaults, which for authentication is probably windows, and session mode would be in process.
Yes, you will be able to run an ASP.NET application without a WEB.CONFIG file in its root folder.
If the application doesn’t find a WEB.CONFIG file in its root folder, then it will take MACHINE.CONFIG file for default configurations. But you will not be able to debug the application as debugging is turned off by default in MACHINE.CONFIG file.
Find more information about machine.config files over here

Extend web.config Application Pool Recycling

I have noticed how editing the web.config file in an application folder causes that application pool to recycle and pick up the changes.
How does IIS achieve this and is it possible to extend this functionality for another config file? Or is this dependency hard-coded somewhere? This is related to the possiblity of deploying configuration changes to a web server without having to edit the web.config, which is usually maintained by a different team.
Note that I don't want to manually invoke this recycle event, but have it work in the same way as with web.config. I'm aware that I could simply add these settings to web.config, but that's not what I've been asked to do.
Many thanks,
Robin
Actually the application pool is not recycle, just rebuild the site.
...to extend this functionality for another config file?
Well, when you change and save the other config file you can call this command to make rebuild the site
HttpRuntime.UnloadAppDomain();

Will enabling a page-level trace in ASP.Net page recycle my application pool?

If I add "trace=true" into my directive on an asp.net 2.0 .aspx page, will it recycle my application pool?
I know if I enable tracing in web.config that will recycle the application pool.
The webserver is IIS 6.0.
Thanks.
I'm not 100% sure but it shouldn't. Any change to a web.config file would cause an app pool reset, but a page level change shouldn't even in the directive.
Check out the section "Why does an application domain recycle?" in this link
Technically if it's the 15th re-compile it could cause a reset... but other than that no.
I believe it will just trigger a recompile of that page. Editing of an aspx file is not a trigger for an application restart.
Why not test it out and see?
Ok - I just tried it out on a testing server - adding in the "trace=true" directive on the page level did NOT recycle the application pool.
It won't. the app pool only recycles when a dll is changed in the Bin directory or if the web.config file is changed. If you are concerned about loosing your session info as that is what the question seems to me to be more related to then you can use the asp.net session state provider and that way your app pool can recycle as many times as it likes without you loosing your session.

Resources