Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Razor outside of ASP.NET

Now that MVC 3 seems to be officially released, do we know if there is official support for using Razor outside of the ASP.NET pipeline.

I know there have been a few post about the how to do this, but none seemed official, and all were a little different.

If there still is no official way to do this can someone point me to the best existing solution?

Thanks!

like image 792
Jaime Avatar asked Feb 25 '23 13:02

Jaime


1 Answers

It really depends on your definition of 'official'.

Yes, Razor was explicitly designed to function outside of the ASP.NET pipeline.

No, there are no official APIs released by the ASP.NET team that would let you run Razor outside of ASP.NET using just one line of code. There's some configuration necessary to make things work.

Andrew Nurse (who implemented Razor) wrote a blog post on what's necessary to create this functionality yourself (http://vibrantcode.com/blog/2010/11/16/hosting-razor-outside-of-aspnet-revised-for-mvc3-rc.html).

I haven't done an exhaustive search but RazorEngine was the first project I'm aware of to build on top of Razor and provide this kind of simple API. I would recomend you start with it and see if it meets your needs.

like image 119
marcind Avatar answered Mar 12 '23 11:03

marcind