question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RazorGenerator not using files on disk if newer

See original GitHub issue

We currently have an issue where we always have to build our project to see changes to razor files, despite UsePhysicalViewsIfNewer being set to true.

I’ve set up a scenario where I can debug RazorGenerator.MVC and, putting a breakpoint into IsPhysicalFileNewer() I can see that it’s not even being called by the framework after the first build for the particular view that I’m interested in.

I’m not sure where to progress to next in order to fix this - any ideas?

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pranavkmcommented, Mar 10, 2016

Views in a separate assembly wouldn’t work. The view engine has no idea where your app is located to cause the refresh.

0reactions
nicholasheadcommented, Apr 4, 2016

Just wanted to add that we’re seeing a similiar/related issue-- but in our case it’s causing an exception to fire; we’re getting an “Object reference not set to an instance of an object.” error about a partial view (_LandingPageFloorContent.cshtml) that uses a model, that actually has nothing to do with the view being rendered/requested (hence empty Model and object reference error). Very odd. Here’s the stack trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   ASP._Views_Shared_PinklesResponsiveElements__LandingPageFloorContent_cshtml.Execute() in C:\_repos\Hireahelper\Hireahelper.Mvc\obj\CodeGen\Views\Views\Shared\PinklesResponsiveElements\_LandingPageFloorContent.cshtml:35
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +147
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +121
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +136
   ASP._Views_Home_Index_cshtml.Execute() in C:\_repos\Hireahelper\Hireahelper.Mvc\obj\CodeGen\Views\Home\Index.cshtml:16
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +147
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +88
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +106
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +374
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +89
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +186
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +67
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +44
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +67
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +399
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137

We’re getting this error after building -> making a change to .cshtml file -> reloading the page. If we build again, the view works properly again until it’s changed.

I think perhaps RazorGenerator is getting confused/collisions on view names – we are trying to load an Home/Index.cshtml view inside of an Area-- but we also have a non-area Home/Index.cshtml in our general Views folder.

I’m going to try and dig further on it, but if this helps anyone on the team with diagnosing, great.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UsePhysicalViewsIfNewer not working · Issue #111
We determine the physical path for files using HostingEnvironment.MapPath . I'm not entirely sure what it would take to map it back to...
Read more >
Razor Generator Build Action - asp.net mvc
The purpose behind Razor Generator is that it pre-compiles your razor views, translating the markup in your cshtml files into C# code that ......
Read more >
An interesting side effect of compiled views - Jeremy Davis
UsePhysicalViewsIfNewer enabled and disabled, with view files present and not present, and using both Partial and ViewRendering bindings. Under ...
Read more >
Sharing Views in MVC — A Quick Start with ...
When you do this, you'll see that a new class — RazorGeneratorMvcStart — was added to the App_Start folder. Step 5: Create a...
Read more >
Helix - Sitecore Shack - WordPress.com
One such issue presents itself when using RazorGenerator. ... Sitecore solution whether it's Helix compliant or not… how we handle old files in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found