Wednesday, February 5, 2014

How to wrap up a static html page into ASP.NET MVC Action?

Without layout, it is very easy
public ActionResult PrivacyPolicy()
        {
            //return View();
            return Content(System.IO.File.ReadAllText(Server.MapPath("~/privacypolicy.html")));
        }


With layout
In Controller
public ActionResult PrivacyPolicy()
        {
            return View();
        }
In view file
@Html.Raw(File.ReadAllText(Server.MapPath("~/privacypolicy.html")))

No comments:

Post a Comment