6

We have an ASP.NET website which uses .NET framework 4.6, and we use rider and visual studio to work on it.

Every once in a while, I have found people getting old razor files that still try to look for functions/references which no longer exist. I understand that those razor files are cached, and we need to clear the cache.

So, we usually go to these steps

  1. Clean %USERPROFILE%\AppData\Local\Microsoft\VisualStudio\\ComponentModelCache
  2. Clean C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root
  3. Clean the \obj and \bin from the project folder structure, wherever applicable.

Some combination of these steps usually work for most people but when it doesnt work, we have to manually go to each razor file (which is complaining with error) and add a space and save it to force clear the cache. Sometimes it a single file or 2 files, but sometimes there are 10 files.

So, would like to know what's the right/recommended way to clear the razor file cache whenever we find this problem again.

11
  • 1
    Whenever I face such cache issues, i will try open the pages in 'InCognito' window or 'InPrivate' mode in IE. Commented Nov 1, 2019 at 11:21
  • 1
    @Thangadurai I don't think its the browser cache issue I am talking about here. Commented Nov 4, 2019 at 7:33
  • Is this something happening in Visual Studio or does this happen when visiting the site through a browser? Commented Nov 4, 2019 at 16:39
  • @GregBurghardt when using the site through a browser. Commented Nov 6, 2019 at 4:43
  • This seems like an IIS configuration issue. Commented Nov 6, 2019 at 11:55

2 Answers 2

0
  1. If you need to clear out the compiled razor files, then "Temporary ASP.NET Files" is the best location, as per this answer.

  2. You could also try to force compilation by adding MvcBuildViews to your build configuration:

    <PropertyGroup>
      <MvcBuildViews>true</MvcBuildViews>
    </PropertyGroup>
    

    See this answer for more information.

  3. If none of the above works, a slightly better workaround than opening all the files and adding a space is to update the file modification time of all your views:

    Get-ChildItem .\Views\ -Recurse | % { $_.LastWriteTime = Get-Date }
    
Sign up to request clarification or add additional context in comments.

Comments

0

try to clear cache
Shift + F5: The Hard Refresh

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.