I am trying out the new razor view stuff in 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 a breakpoints and run the application (console application) I can see that the view is compiled but the debugger does not break when I request the view in the browser. I assume that this is because the views are compiled dynamically at application start or something like that. Is it possible somehow to get the breakpoints to work?
AFAIK it's not possible to debug views this way (currently using 3.9.43, later version I believe has better diagnostics for compilation errors).
Try and keep view code simple, restricted to simple loops/rendering and using extension methods on DTO's for any complex logic/processing, which do allow debugging. You might also consider utilizing 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>
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With