Quantcast
Channel: Create razor view without web - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Filip W for Create razor view without web

$
0
0

If you don't need HTTP to be involved at all, you can simply run Razor engine from C# directly using RazorEngine project - there is a great project that allows you to do so - https://github.com/Antaris/RazorEngine.

It allows you to use Razor as general purpose templating engine (rather than something MVC-specific).

Simple example from GitHub:

string template = "Hello @Model.Name, welcome to RazorEngine!";string result = Razor.Parse(template, new { Name = "World" });

Alternatively, if you still want that to be accessible via HTTP, you could do this relatively easy with ASP.NET Web API, in a very lightweight manner - without having to worry about ASP.NET whatsoever (since you can even self host that).

WebApiContrib has a Razor view formatter already available - https://github.com/WebApiContrib/WebApiContrib.Formatting.RazorViewEngine


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>