I am writing my first razor page today, can't figure out how to enter #if debug #else #endif
How can i enter preprocessor in razor?
I just created an extension method:
public static bool IsDebug(this HtmlHelper htmlHelper)
{
#if DEBUG
return true;
#else
return false;
#endif
}
Then used it in my views like so:
<section id="sidebar">
@Html.Partial("_Connect")
@if (!Html.IsDebug())
{
@Html.Partial("_Ads")
}
<hr />
@RenderSection("Sidebar", required: false)
</section>
Since the helper is compiled with the DEBUG/RELEASE symbol, it works.