I'm using .net MVC 5 to build a web application and trying to implement a method similar to the View() method of the Controller class but only return the evaluated html string.
I have my class Person.cs:
public class Person
{
public string name {get; set;}
public string address {get; set;}
}
And my view template PersonSummary.cshtml:
@model Project.Models.Person
<html>
<h1>Name: @Model.Name</h1>
<p>Address: @Model.Address</p>
</html>
What I want to do is:
Person person = new Person(){ name = "foo", address = "bar" };
string myHTML = myNewFunction("PersonSummary", person);
I do have a current solution (hack) of creating a seperate controller and getting the string from the ActionResult but after something a little more elegant.