Updating an existing ASPX application without success - asp.net

I've a little problem, with a ASPX .NET application that I'm updating.
After having updated the DLL and the ASPX files on the production server, my application is still running not modified.
Is there a method to force IIS reloading the application without restarting the server?

Create the app_offline.htm file on the root of your www, then make your modifications, then delete it (or just rename it)
If you all ready update your dlls, create the app_offline.htm, then just make any small update to web.config (by just add an empty line) save the web.config, then delete the app_offline.htm (or just rename it)
the app_offline.htm, force your application to stop and restart and then the dot net see the changes and recompile it.
When the app_offline.htm is open, all pages show the content of this file, so you can place inside of this file any messages to your viewers.
Visual studio make the same trick when its starts with this file.

Related

Clear Temp ASP.NET files from Azure Web Site

I have a issue with a ASP.NET nopCommerece Plugin that seems to be cached on the server.
I have cleared the nopCommerce cache and restated the application but it didn't help
One of the normal steps is to clear out \Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files but since this is a Azure Web Site, I only have access via FTP and I don't have access to that directory.
How do I go about clearing the Temp Files.
when you publish the website on to azure, by right clicking and choosing publish, there should be a option under setting saying: Remove additional files at destination. Check it and publish.
I managed to do this by creating a temporary file in the bin folder of my website.
This casuses the temporary hash file to change in the temp folder and then ASP.Net rebuilds everything.
See here for more details about the hash file and its relation to rebuilding.
Remove Additional files didn't fix my problem as it only removes files in webroot not the temporary asp.net files. As far as I can see with Azure you have no access directly to the temporary asp.net files

How to constraint IIS app pool from refresh if some files change?

I have ASP.NET MVC application and it contains some folders with files which can be changed in real-time while the application runs in IIS.
When I change certain files with extensions like .resx (without code generation) and .xml (with custom content) my application pool gets refreshed and I don't want this behaviour, however if I change .cshtml then the pool doesn't refresh.
When I put mentioned "problematic" files in App_Data folder then the pool won't be refreshed, but maybe there's solution for other folders too.
For example if I have such folder structure in my application:
App_Code
App_Data
- file1.resx // when its content changes the pool DOESN'T get refreshed
- files2.xml // when its content changes the pool DOESN'T get refreshed
- files3.cshtml // when its content changes the pool DOESN'T get refreshed
CustomFolder
- App_LocalResources
-- file1.resx // when its content changes the pool gets refreshed
-- files2.xml // when its content changes the pool gets refreshed
-- files3.cshtml // when its content changes the pool DOESN'T get refreshed
How to prevent IIS application pool from refresh if some certain files or file types changed?
Thanks for any help.
I think App_Data is a special directory the is ignored for the application restart/reload, since a lot of dynamic/changing content can end up there.
From MSDN about resx files:
The .resx (XML-based resource format) files are converted in to common language runtime binary .resources files that can be embedded in a runtime binary executable or compiled into satellite assemblies.
From that, I think the application is being restarted because the resx file is being compiled at runtime.
I don't think there is a way to prevent this behavior. There are some ideas on How to prevent an ASP.NET application restarting when the web.config is modified? but I haven't tried any of these.
Found a solution.
The problem of app pool recycling when .resx files change was lying in App_LocalResources folder. I moved all the files from this folder to a new folder named Resources (works pretty much the same as App_Data since it's not system folder).
New folder structure looks as follows:
App_Code
App_Data
- ...
CustomFolder
Resources
file1.resx
files2.xml
files3.cshtml

ASP.NET: Writing web-accessible temp files without application restart

My ASP.Net application used to restart unpredictably during requests, ruining my state, session data etc. I determined that the problem was caused by a control that writes and deletes some files in Temp folder that it creates near bin folder, so the web directory looks like this:
bin
Temp
....
Default.aspx
web.config
ASP.Net apparently reacts to changes inside Temp folder the same way it reacts to changes inside bin or in web.config - it restarts the application.
I could partially solve the problem by moving the Temp outside the site directory. That way the application doesn't get restarted every time something temporary is written\deleted, so this part works well. The problem is that some of the files inside Temp directory should be web-accessible - like images generated on the fly and such.
So my question is actually threefold:
Should ASP.Net application get restarted even if the changes are made not in the bin directory, but in another directory at the same level? Or is there something wrong with my configuration?
Where and how do I create a temporary folder so it's web-accessible but it doesn't cause application restart?
How do I turn off restart on directory change from code or web.config (both in IIS and ASP.Net development server)?
Based on my understanding here is the answer to your questions:
ASP.NET restarts the application when too many files are changed in one of the content directories. For more info abt when app restart happens read: http://programming360.blogspot.in/2009/04/what-causes-application-restart.html
You can create the temporary folder anywhere in the same machine or on a different machine(file-share) so long as the IIS-User has access to the folder it should work normally. The only thing that you need to consider is the latency when the folder is on a different computer.
I dont believe you can control application restart and this is completely controlled by IIS. Might want to read up on this SO questions: ASP.NET restarts when a folder is created, renamed or deleted

making changes to an asp.net site without reuploading the whole thing

I'm building a site and for the moment, when I want to put it on the web server, I to go Build > Publish WebSite to a local directory and then on the FTP, I delete the whole existing content and then upload the new fresh content that's on my local directory. In the Publish Web Site popup, I see that there's an option for "Allow this precompiled site to be updatable".
If I make changes to some files in my AppCode directory, how do I update the server WITHOUT essentially shutting it down?
Thanks.
Unless you're using a precompiled site or a web application, all "regular" websites are updateable -- App_Code as well as content.
Precompiled sites can be made to be updateable, but I believe only for web pages, not for code files.
If you have a busy site with lots of updates it's possible that updates can break things until they're complete. You can work around that by creating a file called app_offline.htm at the top level of your site. That will effectively take your site offline as long as it's there. The contents of the file are sent to users instead of your active content, such as *.aspx files. When the update is complete, then remove the file.
Try to take a look here: http://msdn.microsoft.com/en-us/sync/bb840038
All that you need is a Synchronization between VS and server.

"Site is under construction" page for asp.net site

I have to implement ability to show "site is under construction" page during doing some maintenance work on site. There are a lot of ways to implement such behavior (using global.asax file, using IIS and so on). So I would like to know waht is the most used ways of impletenting this feature.
Thanks in advance.
I prefer App_Offline.htm file in the root.
Take a scrape of your site template, stick it in the App_Offline.htm file and place a message in it. Just dropping this file in the root folder of your web site effectively disables your site.
Meanwhile, upload/manage a second instance of the web-site using a temporary domain/URL and when tested/ready, re-point the old site to the new site in IIS.
The change you're deploying now is a simple change to a single page. But sometimes you deploy larger changes, or you deploy both code and database changes, and the site might behave incorrectly if a user requests a page before deployment is finished. To prevent users from accessing the site while deployment is in progress, you can use an app_offline.htm file. When you put a file named app_offline.htm in the root folder of your application, IIS automatically displays that file instead of running your application. So to prevent access during deployment, you put app_offline.htm in the root folder, run the deployment process, and then remove app_offline.htm after successful deployment.
Source: https://www.asp.net/mvc/overview/deployment/visual-studio-web-deployment/deploying-a-code-update

Resources