View does not refresh after change

前端 未结 7 1377
北恋
北恋 2020-12-18 20:16

I am having this frustrating problem. I change text in a razor view (cshtml), Start without Debugging, refresh (Ctrl+F5) the browser but nothing happens. The st

相关标签:
7条回答
  • 2020-12-18 21:12

    Here's what seems to be happening under the hood: the .net framework compiles your razor into a machine-form (DLL) and executes this. It then monitors your web folder to watch for changes, and when it detects changes, it re-compiles your razor and executes the new DLL.

    In your case something seems to fail related to the monitoring file-changes. It still works on a full restart, because then compiling happens even without file-change detection. Common reasons are:

    1. You're serving the files from the network (a NAS or file-share) which doesn't allow your pc to monitor changes. This can be a missing feature (like a non SMB file-share) or a permission issue. This is very common in web-farm scenarios, but probably not your dev-scenario.
    2. Something else is already locking the files (permissions?) which prevents this monitoring hook to hold on to the files.

    To confirm that this is the issue, I recommend just editing the web.config (add/remove a character) and see if then the reload is successful - just to prove it's a re-compile issue and not a visual-studio-debugging issue. Assuming this is the case, and assuming it's not a NAS, I would recommend to temporarily give the folder a "everyone - everything" permission to see if it works then, and then gradually reduce the permissions again to where you want them.

    0 讨论(0)
提交回复
热议问题