-1

We have an ASP.NET MVC website in C#, and when they publish new code, they don't usually restart the web server. This can cause problems because some code changes might assume that new code called in App_Start fired, or some lookup values in static variables might be outdated relative to code changes.

What I'm thinking of doing to solve this problem is to have a static variable set to AssemblyName.Version. Then on any web request, I would have code check AssemblyName.Version against the static variable, and if it's different, it would update that static variable and run certain code to refresh caches and perform certain tasks that would normally be run by App_Start.

What I'm wondering is whether there's any better way of handling this. Surely this is a common situation, so I'd be curious how others are handling this.

Nickadoo
  • 104
  • 2
  • 7
  • 1
    It’s really hard to understand what you’re asking. – maccettura Feb 11 '18 at 04:42
  • 1
    I would tell IT to get their act together (or the deployment team). – CodingYoshi Feb 11 '18 at 04:49
  • `We have an ASP.NET MVC website in C#, and when they publish new code, they don't usually restart the web server. ` That is your problem. Deal with that problem rather than the symptoms. You need a relatively automated deployment pipeline rather than what you have now (which sounds like basically 'manual file copy'). – mjwills Feb 11 '18 at 05:53
  • Well, as previously commented, a `web.config` change will _restart your **application**_. [So do changes in assemblies in your `/bin`](https://social.technet.microsoft.com/wiki/contents/articles/34854.iis-restart-requirements-after-configuration-changes.aspx), which I'm _assuming_ is what you meant by _"publishing"_ – EdSF Feb 11 '18 at 06:07

1 Answers1

1

Put the version number or something unique in the web.config file. This will trigger ASP.NET runtime to restart the application. You do not need to do nothing with it, so long as it is there and it is different from the previous web.config, it will do the job.

But I still think you should tell your deployment to get their act together; you cannot babysit them. If their job is to deploy, they should know how to do it. Forgetfulness is not a good reason.

CodingYoshi
  • 25,467
  • 4
  • 62
  • 64