Reputation: 673
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.
Upvotes: 2
Views: 918
Reputation: 3242
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
Upvotes: 2