简体   繁体   中英

How to correctly publish and update an ASP.NET app in IIS

I have an issue every time I update my ASP.NET application on my IIS server. The issues are:

  • I get an error telling me to turn custom errors off <customErrors mode="Off"/>
  • The default web site redirect at the TLD redirects the URL indefinitely
  • I created removed and replaced the App or the redirect

I have an ASP.NET 4.5 Framework application. I am using Visual Studio 2012 to create the web application. I am using Windows Server 2008 R2 64 bit, with the IIS 7 role installed. Every last option for the IIS role was checked and installed.

Once IIS is up and running, I created a directory in C:\\inetpub\\wwwroot and put my published ASP.NET app in the directory that I created. I then added the app via IIS manager.

在此输入图像描述

After that I can browse to my app from www.example.com/app. The current app is working. Since I want anyone who types in my TLD in the web browser to be redirected, I created an HTTP redirect via IIS manager under Default Web Site. It creates a web.config file in C:\\inetpub\\wwwroot with the redirect in it.

After all of this is done everything works great. That is until I want to update the ASP.NET code. I delete the old files from C:\\inetpub\\wwwroot\\app and copy in the new files. After that nothing works right anymore. I have tried to remove the app via IIS then re-adding it. I even removed the http redirect, and then re-added it. No matter what I do the root of my site www.example.com and the web app won't work. I have to remove the IIS role and reinstall it. Once I do that the current code works, and everything is back to normal.

Can someone please tell me how I can update my code with having to reinstall IIS every time?

Once you created the the redirect in IIS, it created the redirect in the web.config file in C:\\inetpub\\wwwroot

Little did you know it also creates one in your app folder. Which is all good till you try to update the code. Since you erase the files in that folder when you publish (or at least that was pobably your settings) that file was removed.

You have to append your publish files not delete them since you ask IIS to redirect for you :)

when you update the files, please refer the old web.config file which is running previously. just make sure that if you modified the references or assembly in the code, then refer the new web.config file else the old file will work instead of reinstalling IIS services.

Check the folder permission settings from folder properties->secuirty->advanced settings after you update your files. if the subfolders change their settings everytime you update then that might the problem.

Is it feasable to have a app_offline.htm that displays a message like "this site is momentary down for maintenance, please check again later"?

Such a files allows you to update your site, without any nasty error messages.

Show us the settings of the application pool.

Could be many issues such as permissions to the file system for the user context running the application pool.

Could be permission to a database.

We need a bit more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM