where should i encode this html data in an asp.net mvc site

Posted by ooo on Stack Overflow See other posts from Stack Overflow or by ooo
Published on 2010-05-26T14:54:08Z Indexed on 2010/05/26 15:01 UTC
Read the original article Hit count: 240

here is my view code:

<%=Model.HtmlData %>

here is my controller code:

    public ActionResult GetPage()
    {
        ContentPageViewModel vm = new ContentPageViewModel();
        vm.HtmlData = _htmlPageRepository.Get("key");
        return View(vm);
    }

my repository class basically queries a database table that has the fields:

id, pageName, htmlContent

the .Get() method passes in a pageName (or key) and returns the htmlContent value.

Right now i have just started this (haven't persisted anything to the db yet) so i am not doing any explicit encoding in my code now.

What is the best practice for where i need to do encoding (in the model, the controller, the view ??)

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about encoding