2

In an MVC application, my /Views/Content/Details.cshtml page has the following:

@model example.Models.Content

@{
    ViewBag.Title = "Details";
}

@Html.DisplayFor(model => model.Description)

This works as expected. The web browser produces the data in the "Description" column from the SQL database.

For testing purposes, I configured an entry in the Description column with the following data:

<p>This is a test</p>

The Web Browser displays <p>This is a test</p>, which is to say that the Web Browser is displaying the markup.

This post and this post and this post mention that @Html.Raw(model.Description) should resolve this issue. I revised my code to this:

@model example.Models.Content

@{
    ViewBag.Title = "Details";
}

@Html.Raw(model.Description)

The Web Browser now produces "An error occurred while processing your request". I am certain I must be overlooking something simple here, but I am just not seeing the cause of the problem.

Community
  • 1
  • 1
JeremyCanfield
  • 633
  • 11
  • 24
  • 1
    try to use `@Html.Raw(Model.Description)` instead of `@Html.Raw(model.Description)` capital `M` in for `Model`.. Hope it resolve your issue .. – Sunil Kumar Jul 30 '16 at 04:22
  • Oh my, I did not know that this was CaSe SenSiTiVe. Thank you very much @SunilKumar. If you want to submit this as an answer, I will accept your answer. – JeremyCanfield Jul 30 '16 at 04:25

1 Answers1

2

You are using small m for binding Model as in asp.net MVC the Model bindings are case sensitive You have to you your code as following way : Use :

@Html.Raw(Model.Description)

instead of using

@Html.Raw(model.Description)

You have to use Capital M for binding your Model.

Thanks

Sunil Kumar
  • 3,142
  • 1
  • 19
  • 33