How do you restart an asp.net web forms application? - asp.net

I am getting this error after publishing my application:
The directory '/App_GlobalResources/' is not allowed because the application is precompiled.
My googling has yielded many recommendations to "restart my application" only I have no idea how to do this.

To restart your application you can open web.config in an editor, add a space somewhere, and save it. Please be aware that if you are using in-process session state the application pool will recycle, causing session state to be lost. However, this method has the benefit of not affecting web applications in other application pools.
If you want only this application to be affected, you could place it in its own application pool, or use one of the other session-state modes. Session State Modes

Refresh your website and Restart your application pool from IIS.

If you're developing locally, open a command prompt and type iisreset If you do this on a production machine you're going to take ALL the sites on that machine down during the reset. It's usually quick, but some sites can't have downtime during peak hours...
On a server, stop the app and app pool, then start them again.

Related

IIS restarts suspended aplications after configuration change

I have encountered a (mis?)behavior of IIS/ASP.NET related to app pool suspension (Idle Worker Process Page-Out), and I can't find documentation about it. When an ASP.NET app (.NET Framework 4.8) in IIS (10.0) is suspended, and then a change is made to IIS configuration, the next time the app is accessed, it restarts (new AppDomain in same w3wp process).
It doesn't matter What is changed in IIS (appcmd add apppool, appcmd add app, etc.). Even touching applicationhost.config (changing LastWriteTime without content change) is enought to fire a restart. To be clear, the restart only happens if the app is SUSPENDED when IIS configuration is changed, and not if the app is live.
We have a lot of apps in the same IIS server, with frequent app deployments, and each time a deployment is made, all the suspended apps are affected (next user must wait the restart time). This renders useless the suspension mechanism. ¿Is this restart behavior by design or it's a bug? ¿Is there a way to prevent it?

Everytime we publish our .NET app on Azure, users are logged off

Everytime we publish our .NET app on Azure, all users are bein logged off and to sign in again, what our users won't understand. The user sessions are implemented using the SimpleMembership provider.
Is there any way to keep user sessions alive, even after we update our app?
I think you have misunderstood what publishing does. When you publish the application it will create a new instance of the w3wp.exe process. This is the web process where the application memory is stored (keeping it simple). If you publish you are creating a new instance and the old is getting destroyed.
All sessions will be lost.
For example, every time you publish the website, it will make a change to web.config. This will cause the application to unload and IIS to recycle.
Causes:
Web.config Changes
bin folder content change
Manual IIS
applicaiton pool recycle
If you need to keep your sessions alive then you should look at Session-State Modes

iis7 application pool hanging

I have a .net 4.0 website that was running on physical Windows server 2003 boxes on IIS6 32bit just fine. We have migrated to new virtual servers running Windows Server 2008 32 bit with IIS7. The application pool is running in classic mode.
Since the move, I at random get a situation where the application hangs. The request queue rockets and then I get 503 errors. If the application pool is recycled, then the error goes away till the next time it occurs.
There are no entries in the event logs relating to it except that it notes when the application pool took to long to shut down during the recycle process. I have reporting in my .net application that logs to a DB and sends me errors but it sends me nothing when this application is hanging.
What tools can I use to diagnose the problem and figure out what is causing it?
In opinion, whatever the structure of application is, if you're pretty sure that there is no bug, changing sort of properties on the application pool might solve the problem.
First on the 'Advanced Settings...' menu of the application pool change the 'Enable 32-Bit Applications' to the relevant value. If the platform used for building application is x86 then the value should be 'True'.
Second if your application demands to access disk resources, also you should the relevant security context for running the application pool in the 'Identity' property. The identity should access all the directories that your application wants to change or list.
After doing all the things, in case the problem existed, you should let me know about the platform of your application. Is it .NET or ISAPI?
Cheers

Application Pools not starting after iisreset

Before I start, I know using iisreset is considered bad practice, but this shouldn't happen anyway..
What we have:
Several machines with IIS6 on Windows Server 2003 R2 (both 64 and 32 bits)
Several WCF webservices (.NET runtime 2.0) deployed in several applications, each with it's own application pool, each application pool running under an other windows account.
What happens:
All appPools are started, all services operational
IISReset is executed (or the machine is rebooted)
IIS comes back up, but not all application pools start properly. Sometimes they all come back up, sometimes one or more pools won't start. They can be started manually however.
Is this "normal" iis behavior and should I just avoid using iisreset, or are we doing something wrong in our .NET code?
The application pools should restart on an iisreset, but they do run outside of iis (in COM+) for reliability. This mean they may may not come back if the application is misbehaving, but IIS and the other apps will(should) come back. So yes, This is "normal".
P.S.
I would also like to "OUT" myself as a proud user of iisreset. Bad practice? Bah! ;D
IIS does not immediately start ASP.NET worker processes (w3wp.exe) until the first request comes in. When you say "not started", does it mean you attempt to access some WCF web services (after iisreset), and you get a Service Unavailable error because the appPool cannot be started? Do you see any IIS W3SVC related entries in the Event logs?
If there are, they may be able to clue you in why they cannot start; post them up here.
Reason:
IIS does not immediately start ASP.NET worker processes (w3wp.exe) until the first request comes in. When it says "not started" it mean you attempt to access some WCF web services (after iisreset) failed due to object was holding some space in memory, and you get a Service Unavailable error because the appPool cannot be started.
Workaround:
Create Batch file with following commands & schedule it.
net stop 23svc
net stop msftpsvc
net stop smtpsvc
net stop PleskControlPanel
net stop HTTPFilter
iisreset /restart
net start w3svc
net start msftpsvc
net start smtpsvc
net start PleskControlPanel
net Start HTTPFilter
Had similiar issue - after IIS has been restarted, DefaultAppPool was stopped.
In application event logs found an error:
Windows cannot log you on because your profile cannot be loaded. Check that you are connected to the network, or that your network is functioning correctly. If this problem persists, contact your network administrator.
DETAIL - Access is denied.
Fixed by setting in DefaultAppPool Advanced Settings option Load User Profile to False.
Hope it could be usefull.
In a prior support role, I managed several IIS servers running all kinds of .NET mess. When an AppPool failed to start, it was usually a bad login credential.
Re-setting the identity (auth credentials) via advanced settings of the Application pool worked for me.
Earlier I changed my active directory password and as the app pool was already running, it worked fine until I performed IISRESET.

What does 'IISReset' do?

On IIS 6, what does an IIS reset do?
Please compare to recycling an app pool and stopping and starting an ASP.NET web site.
If you replace a DLL or edit/replace the web.config on an ASP.NET web site is that the same as stopping and starting that web site?
IISReset stops and restarts the entire web server (including non-ASP.NET apps)
Recycling an app pool will only affect applications running in that app pool.
Editing the web.config in a web application only affects that web application (recycles just that app).
Editing the machine.config on the machine will recycle all app pools running.
IIS will monitor the /bin directory of your application. Whenever a change is detected in those dlls, it will recycle the app and re-load those new dlls. It also monitors the web.config & machine.config in the same way and performs the same action for the applicable apps.
IISReset restarts the entire webserver (including all associated sites). If you're just looking to reset a single ASP.NET website, you should just recycle that AppDomain.
The most common way to reset an ASP.NET website is to edit the web.config file, but you can also create an admin page with the following:
public partial class Recycle : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpRuntime.UnloadAppDomain();
}
}
Here's a blog post I wrote with more info: Avoid IISRESET in ASP.NET Applications
It operates on the whole IIS process tree, as opposed to just your application pools.
C:\>iisreset /?
IISRESET.EXE (c) Microsoft Corp. 1998-1999
Usage:
iisreset [computername]
/RESTART Stop and then restart all Internet services.
/START Start all Internet services.
/STOP Stop all Internet services.
/REBOOT Reboot the computer.
/REBOOTONERROR Reboot the computer if an error occurs when starting,
stopping, or restarting Internet services.
/NOFORCE Do not forcefully terminate Internet services if
attempting to stop them gracefully fails.
/TIMEOUT:val Specify the timeout value ( in seconds ) to wait for
a successful stop of Internet services. On expiration
of this timeout the computer can be rebooted if
the /REBOOTONERROR parameter is specified.
The default value is 20s for restart, 60s for stop,
and 0s for reboot.
/STATUS Display the status of all Internet services.
/ENABLE Enable restarting of Internet Services
on the local system.
/DISABLE Disable restarting of Internet Services
on the local system.
Application Pool recycling restarts the w3wp.exe process for that application pool, hence it will only affect web sites running in that application pool.
IISReset restarts ALL w3wp.exe processes and any other IIS related service, i.e. the NNTP or FTP Service.
I think changing web.config or /bin does not recycle the whole application pool, but I'm not sure on that.
It stops and starts the services that IIS consists of.
You can think of it as closing the relevant program and starting it up again.
Editing the web.config file or updating a DLL in the bin folder just recycles the worker process for that application, not the whole pool.
IISReset restarts the entire webserver (including all associated sites). If you're just looking to reset a single ASP.NET website, you should just recycle that Application Domain.
When you change an ASP.NET website's configuration file, it restarts the application to reflect the changes...
When you do an IIS reset, that restarts all applications running on that IIS instance.
Here what's technet has to say about iisreset
You might need to restart Internet Information Services (IIS) before certain configuration changes take effect or when applications become unavailable. Restarting IIS is the same as first stopping IIS, and then starting it again, except it is accomplished with a single command.

Resources