1

Currently i use <% %> tags in web forms view engine to generate dynamic content; however it has some limitations, while MVC razor engine has a very powerful syntax and does not have web forms view engine.

Can i use razor view engine in existing Asp.net web forms application?

Gray
  • 7,050
  • 2
  • 29
  • 52
r.zarei
  • 1,261
  • 15
  • 35

1 Answers1

0

you can use razor engine, only add razor package at your project, i working with VS 2012, and work, use this

Before create some directory to put your templates, for example "Views"

string viewPath = Server.MapPath(@"~/Views/yourTemplate.cshtml");
var teamplate = System.IO.File.ReadAllText(viewPath);
string view = RazorEngine.Razor.Parse(teamplate, model);

model is any class with properties (setter and getter);

In your cshtml file put this sentence at the top

@{

    Layout = null;
}