HTML恩code德code C#MVC4 [英] HTML encode decode c# MVC4

查看:213
本文介绍了HTML恩code德code C#MVC4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在升级AC#MVC2项目到C#MVC4的过程。

I am in a process of upgrading a c# MVC2 project into c# MVC4.

下面是该方案在MVC2

输入字符串(从数据库)

Input string(from database)

   Model.text="<p>Hi<br>hello!<br>you there</p>"

输出(在视图中呈现的)  使用渲染

Output (rendered in the view) rendered using

 <%=Model.text %>

Hi
hello!
you there

下面是场景MVC4

输入字符串(从数据库)

Input string(from database)

   Model.text="<p>Hi<br>hello!<br>you there</p>"

输出(在视图中呈现的)  使用渲染

Output (rendered in the view) rendered using

@Model.text

<p>Hi<br>hello!<br>you there</p>

我试过

@HttpUtility.HtmlDecode(Model.text) 
@HttpUtility.HtmlEncode(Model.text) 

没有什么帮助......

Nothing helps...

我在MVC4 这里问(阿贾克斯结果与HTML标签不实际的HTML)呈现

I had a similar problem in MVC4 asked here (the ajax result is rendered with html tags not the actual html)

是我的一些设置,困扰我吗?或者是说是与HTML 5还是我失去了使用MVC4什么。 请帮助!

Is some of my settings troubling me??? or is that something to do with HTML 5 or am I missing anything in using MVC4. Please help!!

推荐答案

@ Html.Raw(Model.text)应该做的伎俩。

@Html.Raw(Model.text) should do the trick.

这篇关于HTML恩code德code C#MVC4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆