0

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.

desperate man
  • 905
  • 1
  • 17
  • 39

2 Answers2

1

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.

Community
  • 1
  • 1
Steven V
  • 16,357
  • 3
  • 63
  • 76
  • Yeah, you are right about **.resx**, but why **.xml** is acting the same way this is very strange. Solutions provided in the given link don't seem to be very good. Thank you anyway. – desperate man Jul 18 '13 at 13:43
  • I'll agree, the XML kicking things off again is weird... especially if that's the only file you're placing in there. I don't have an answer to that part. – Steven V Jul 18 '13 at 13:47
0

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
desperate man
  • 905
  • 1
  • 17
  • 39