2

We have this very strange error in Asp.Net MVC 4 Razor whereby within the View, we have the following code:

@Html.InlineEditingContentText(CS.General_v4.Enums.HtmlTagName.Span, VisitGozo.Enums.VisitGozoEnums.ContentTextIdentifier.MasterPage_Weather_Title, "weather-widget-title masterpage-widget-title")

InlineEditingContentText is an extension method which we have internally. The 2nd parameter being passed is an enumeration parameter and as you can see from above, the value is VisitGozo.Enums.VisitGozoEnums.ContentTextIdentifier.MasterPage_Weather_Title. Now when you debug into the extension method InlineEditingContentText, the actual 2nd parameters being received is not VisitGozo.Enums.VisitGozoEnums.ContentTextIdentifier.MasterPage_Weather_Title but VisitGozo.Enums.VisitGozoEnums.ContentTextIdentifier.MasterPage_Header_LoggedOutText which happens to be the next value of the ContentTextIdentifier enumeration after VisitGozo.Enums.VisitGozoEnums.ContentTextIdentifier.MasterPage_Weather_Title.

We are not assigning values to the enumerations and so their respective int values increment after each other automatically.

  • Strangely enough, if we load the exact same project on another workstation, this works fine.
  • Also, if we perform some changes to the View (like just add a whitespace) and save, this also works fine.

Any possible insight into why this strange issue is happening?


Edit #1: Also, when we uploaded the website on the deployment server, after compiling using same workstation, the error was carried over as well

Edit #2: 2013-10-22 > We are still getting this same problem, even when then deploying the files on the actual production server, such incorrect enum values are being carried over. The only way to solve the issue is to delete the Views from the server / locally, and re-overwriting them again. Any idea how we can solve this issue? We shouldn't be caching Views so can't really understand why this is happening? Would appreciate any form of help!

6
  • 4
    Sounds like it was possibly last compiled when the enum had a different set of values. Commented Oct 2, 2013 at 17:17
  • @JonSkeet, we rebuilt and cleaned the entire solution, yet still the error stayed Commented Oct 2, 2013 at 17:23
  • I suspect it didn't clean fully - that would explain everything, including adding a whitespace to the view fixing it. I suspect there are any number of places that the compiled view could be cached without you realizing it. Commented Oct 2, 2013 at 17:24
  • @JonSkeet Any suggestion towards what we could do in order to fix such an issue of views being cached? This is happening locally on the workstation using the Asp.Net development server where the solution is being run & built every time before running. We have even tried removing Asp.Net temporary files, and still problem persisted. Commented Oct 2, 2013 at 17:45
  • So having "fixed" it with the whitespace change, it breaks again? That does sound very odd... Commented Oct 2, 2013 at 17:46

1 Answer 1

1

Most likely cached files have not been cleaned. It might happen occasionally.

  • If you use IIS delete corresponding Temporary ASP.NET folder. For example, if your project is 64bit Framwork 4.0 then path would be: %WinDir%\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\

  • If you use IIS Express or similar you might need to stop it and start again.

Updating Razor file forced dynamic compilation and that solved the your issue.

Sign up to request clarification or add additional context in comments.

5 Comments

I tried to clear temp asp.net folder but still didn't work out. I restarted Visual Studio and even restarted workstation and still nothing
If you use IIS that's 100% solution to clear dll cache. Perhaps you deleted wrong folder? Check your app-pool settings.
We use the Asp.Net development server through Visual Studio
In those cases stooping ASP.NET development server in Taskbar works. Then Visual Studio starts new one with cleared cache. Temporary ASP.NET folder is used only by IIS.
This is even happening if you have your workstation switched on, load visual studio locally and run it through IIS express / Visual Studio so I can't imagine that it will still be cached?

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.