4

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.

enter image description here

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?

pixelmeow
  • 654
  • 1
  • 9
  • 31
nate
  • 1,418
  • 5
  • 34
  • 73
  • 2
    That message telling you to turn customErrors mode Off isn't your actual error. It's directing you to do that because there's some underlying error, but it won't show the actual error by default unless your browse to it on localhost (for security purposes). It's bad practice to leave customErrors off (unless it's just temporary). Instead, implement proper error logging such as [Elmah](https://www.nuget.org/packages/elmah/). Once you've determined what the actual error is, you'll be able to troubleshoot your root cause. – mason Jun 27 '14 at 18:21
  • I am not sure but have you tried "updated" (not deleting and replacing files) the application folder on IIS without your, web.config? – Karthik Ganesan Jun 27 '14 at 18:25
  • @mason There isn't any errors. Once I remove and reinstall IIS everything works fine with the new updated the code – nate Jun 27 '14 at 18:25
  • Don't remove and reinstall IIS-try to get at the actual error message so you can figure out what the underlying problem is (check the Event Logs on the server, or set customErrors=Off.) – mason Jun 27 '14 at 18:29
  • @KarthikGanesan Which web.config? The one in my ASP.NET app folder, or the one that IIS created to redirect? – nate Jun 27 '14 at 18:30
  • @nate try not deleting both – Karthik Ganesan Jun 27 '14 at 18:31
  • Just a guess, but perhaps the problem is that both apps are under the same root folder? Perhaps you could put both apps into sibling folders: `wwwroot\redirect` and `wwwroot\app`. – chue x Jun 27 '14 at 19:36
  • @chuex I think you are on to something with the redirect. But there is only one app. There the redirect is just a web.config @ the root of wwwroot – nate Jun 27 '14 at 19:42
  • It seems to me it is still two apps - you are using the default app for the web.config, correct? The default app is one app, your app is another. – chue x Jun 27 '14 at 20:23
  • @chuex THere is only one app setup via IIS. When I created the http redirect via IIS on the "Default Web Site" to redirect www.example.com to www.example.com/app IIS created another web.config with the redirect to the app in it. – nate Jun 27 '14 at 20:37
  • 1
    Once you created the directory in C:\inetpub\wwwroot did you try to refresh the web site from IIS manager, right click on the folder and choose Convert to Application in order to avoid "mixing" application config and web site config – NicoD Jun 30 '14 at 09:55

6 Answers6

1

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 :)

jth41
  • 3,808
  • 9
  • 59
  • 109
0

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.

Aslam
  • 93
  • 1
  • 4
0

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.

ilzie
  • 28
  • 1
0

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.

0

i found an AMAZING tutorial that solved this very issue for me... I do have to agree in regards to the web.config file, use your current one ( make a copy of it, if you have your publish settings set to delete the old files - i made that very same mistake and found myself having to re-grant access to my wwwroot folder as well as my database for some reason).

this tutorial is what helped me through my process to get my app installed, then updated as well.

ALSO

  • If you're only making changes to your views or css files, you can simply copy and paste your updated views into that folder - i found that to be much less invasive than having to republish the entire project on each update.

check out the link below to get help with publishing and configuring IIS and SQL server

https://www.codeproject.com/Articles/674930/Configuring-IIS-ASP-NET-and-SQL-Server

seancago
  • 11
  • 1
-1

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.