Get stack trace from razor macro within umbraco
Asked Answered
R

3

8

I've inherited a code base that is built on umbraco. It is using razor scripts to render the views.

Whenever there is an error I get something like this in the output:

Error loading Razor Script Product.cshtml
String reference not set to an instance of a String. Parameter name: s

As you can see that is pretty useless in helping identify the error.

I've no idea if this is an umbraco or razor issue (first time I've used either) Is there a way that you can turn on proper stack traces?

Raimund answered 4/9, 2012 at 19:16 Comment(0)
H
24

Put umbDebugShowTrace=true in your querystring to see the full stack trace. Make sure umbracoDebugMode is set to true in your appSettings and trace is enabled.

Harrison answered 4/9, 2012 at 19:24 Comment(5)
That does the trick! I don't suppose there is a way to always show the stack trace with the error though?Raimund
No there is not, a stack trace contains sensitive information that should not be displayed when you're not asking for it (a hacker could grab the juicy bits).Harrison
Sure, but if umbracoDebugMode is already set to true it does imply you want that info :-) anyway you've solved my problem so thanks!Raimund
For live environments you absolutely want to make sure umbracoDebugMode is set to false so your sensitive info will not be exposed. That said, we've had a few discussions as to how we can show more useful info on razor errors, food for thought. This Chrome extension can help you easily switch to debug mode by the way: bit.ly/fXzlk8Harrison
Ahh the extension is cool as I will surely forget what the params are :-)Raimund
F
2

It's a very good idea to create a website project in Visual Studio and work with your Razor scripts in there. You can Debug > Attach to Process and then set breakpoints, watches, step through your code etc, just like any other program.

Factious answered 20/9, 2012 at 14:53 Comment(0)
R
0

Adding to Sebastiaan's post, you set umbracoDebug and trace to true in the main web.config for the Umbraco installation. This gives fuller info on the error.

Rhyton answered 15/10, 2013 at 3:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.