Can I set breakpoints as a razor using the utility?

I am trying to use a new razor view in the service stack, and I have this view:

@inherits ServiceStack.Razor.ViewPage<ServiceStackRazorCrud.Api.UserPageResourceResponse> @{ var m = Model; // <-- I have a breakpoint in this line. var req = Request; var res = Response; } 

When I set breakpoints and run the application (console application), I see that the view is compiled, but the debugger does not interrupt when I request the view in the browser. I assume this is because the views compile dynamically when the application starts, or something like that. Is it possible to somehow make breakpoints work?

+7
source share
1 answer

AFAIK is not possible to debug views this way (currently 3.9.43 is used, a later version, I believe it has a better diagnosis of compilation errors).

Try to keep the viewing code simple, limited to a simple loop / rendering, and use extension methods for DTO for any complex logic / processing, which allows you to debug. You can also consider using logging or a simple debug extension method:

 using ServiceStack.Html; public static class HtmlHelperExtensions { public static bool IsDebug(this HtmlHelper htmlHelper) { #if DEBUG return true; #else return false; #endif } } @using ServiceStack.Text @inherits ServiceStack.Razor.ViewPage<ServiceStackRazorCrud.Api.UserPageResourceResponse> @{ var m = Model; } @if (this.Html.IsDebug()) { <div class="debug">@(this.Model == null ? "m == null" : Model.Dump())</div> } 
+3
source

All Articles