1

I have TypeScript files outside of my ASP.NET MVC applications.
These TypeScript files are common for multiple web apps.

Previously, if one modified a TypeScript file, a watcher automatically built it into js, but after that, one had to build the project or run a script copying the .ts and .js files into the web app's folder (~/Assets/js), from where they are served.

Now we tried to hard-link the TypeScript root folder as NTFS directory junction into ~/Assets/js.
The plan with this was to speed up development time, because if it'd worked, one only had to edit the TypeScript files in one place, and save them. No copying would be necessary to the output folder, since the files are linked there.

The results are not as expected. Sometimes, the edited files get refreshed (when reloading a page using them in browser), sometimes not.

Later I've read FileSystemWatcher does not work with directory junctions, so I'd expect IIS uses a FileSystemWatcher, which does not emit any change event if a developer changes a .ts file in its original, common place (where the junction points to).

I guess this is the case anyway, but somehow, sometimes the files get refreshed, I don't know how.

I could check with Fiddler, when the files are served wrong - the old version of the file is served, without the modifications - it is not cached in browser, but sent by the server.

Possible questions:

  • How to solve this? :)
  • How to disable file caching in IIS (Express) for development?
  • How to properly link directories in IIS with change tracking working?
Kev
  • 118,037
  • 53
  • 300
  • 385
nvirth
  • 1,599
  • 1
  • 13
  • 21
  • Is there a reason you're using junctions to map these common folders into your sites instead of mapping them in using virtual directories? I suspect this would solve your problem. – Kev Nov 21 '19 at 17:28
  • You mean IIS virtual directory? Can I setup smg in Web.config? Pointing outside of the MVC project? – nvirth Nov 21 '19 at 17:49
  • Not sure what you mean by "smg"? But you can point IIS virtual directories at folders outside of your site's root. You just need to make sure you've assigned the correct permissions for your site's application pool to read that "external" physical directory. – Kev Nov 21 '19 at 18:07
  • How can I do that? Can it be done in Web.config? Please point me to an example – nvirth Nov 21 '19 at 18:24
  • Are talking about on your production IIS environment (Windows Server) or in IIS Express (Visual Studio)? – Kev Nov 21 '19 at 18:28
  • Both, as our developers use both IIS and IIS Express as well for development. We need an universal solution, which works both while development and on the build server – nvirth Nov 21 '19 at 18:33
  • 1
    It sounds like an output caching but IIS express should not save output cache unless you set rule for specific extension. Have you tried to disable client cache header in IIS like ? – Jokies Ding Nov 22 '19 at 09:25
  • `NoControl` is the default value ([msdn](https://learn.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/clientcache)). I tried `DisableCache`, that did not work – nvirth Nov 22 '19 at 13:28
  • Tried these, none of the worked: `` `` `` Also checked `netsh http show cachestate`. Before the previous changes, it contained items. After them it always remained empty. But the .ts files still get stuck. – nvirth Nov 22 '19 at 16:18

0 Answers0