Razor kick

I have no doubt set something wrong, but I often get exceptions thrown by my Razor templates, even though there are no template issues. They are usually fixed when the assembly is created.

If I do have an error in the template, I get a popup asking me to debug it in VS, but of course this prevents me from debugging the template.

The errors in my log are not all helpful (see below).

Is it possible to avoid false errors and get better information if there is a problem?

ServiceStack.Razor.Templating.TemplateCompilationException: Unable to compile template. Check the Errors list for details.
   at ServiceStack.Razor.Templating.TemplateService.CreateTemplate(String template, Type modelType)
   at ServiceStack.Razor.Templating.TemplateService.Compile(ViewPageRef viewPageRef, String template, Type modelType, String name)
   at ServiceStack.Razor.Templating.TemplateService.Compile(ViewPageRef viewPageRef, String template, String name)
   at ServiceStack.Razor.ViewPageRef.Compile(Boolean force)

      

+3


source to share


3 answers


I had similar problems. I found the "easiest" way to figure out where the error was: load the entire service stack, build a debug version of the razor library, and link it to my project. Then I set a breakpoint in the ServiceStack.Razor.Templating.TemplateService.CreateTemplate method and was able to see the full details of the exception. From there I found out that I included an import on my razor page that my project did not link to.



Since I solved this, it has been very reliable.

+2


source


I had problems with this myself because ServiceStack swallowed exceptions and the logs, as you said, don't show a collection of errors. There are two ways to get this information:



+2


source


I had the same problem. And in my case, I removed some libraries that were referenced in the project, but the link to them remained (eventhought, I think, removed it, but anyway) and that was the problem. After I removed references to libraries that are no longer used in the project, it worked right away.

+1


source







All Articles