I have a Razor .cshtml template with the following:

As you can see, @Model can't be resolved.
However, when I parse the template with the following code:
public static string RenderPartialViewToString(string templatePath, string viewName, List<ZonesVM> zonesVm)
{
string text = File.ReadAllText(Path.Combine(templatePath, viewName));
string renderedText = Razor.Parse(text, zonesVm);
return renderedText;
}
it works correctly, and I see the result I expect to in the HTML.
Is there a way for me to get Razor to know what @Model is before it's compiled?
For reference, I'm using RazorEngine and not the ordinary MVC Razor stuff.
You're already in a code block. You don't need the @ before model. The @ is used to transition into a code block from html.
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