toddams / RazorLight

Template engine based on Microsoft's Razor parsing engine for .NET Core
Apache License 2.0
1.5k stars 259 forks source link

[Question] How to debug the cshtml template in VS 2017, Core 2.0 and RazorLight v2.0.0-beta1 #206

Open BrunoCandia opened 6 years ago

BrunoCandia commented 6 years ago

Hi,

I am not able to debug the razor template in VS 2017, Core 2.0 and RazorLight v2.0.0-beta1

I'm working in a Web.Api project and in my controller I have the following:

        var codeBase = Assembly.GetExecutingAssembly().CodeBase;
        var uri = new UriBuilder(codeBase);
        var dir = Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path));
        var template = File.ReadAllText($"{dir}/Templates/{templateName}.cshtml");

        var engine = new RazorLightEngineBuilder()
            .UseMemoryCachingProvider()
            .Build();

        var result = engine.CompileRenderAsync("templateKey", template, data).Result;

I tried different ways without success, how can I do to debug the razor template ?

Thanks.

markleacompassphs commented 5 years ago

I have had the same experience, debugging does not work. Your best bet is to just let the rendering fail and you might get an error message but not always, sometimes it just does not render the html in the problem areas.