我正在做一个维护页面,人们可以在其中存储资源文件中将要说的内容的描述,此时在要求中他们甚至不知道文本是纯文本还是具有类似<a></a>. 所以在这一点上,我必须假设情况会如此。
这个proyect是在VS2010的Webforms framework 3.5中制作的。
为了简单起见,我将揭示相关部分:
<article>
<img alt="an image" src="Images/logo.jpg"/>
<h2>Site under Maintenance</h2>
<div>
<p id="Description"></p>
</div>
</article>
<script src="Includes/jquery-1.12.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "GET",
url: "MaintenanceSite.aspx/GetMaintenanceDescription",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$("#Description").text(msg.d);
}
});
});
</script>
后端:
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public static string GetMaintenanceDescription()
{
string mensaje = HttpUtility.HtmlEncode(Resources.MaintenanceDescription);
return mensaje;
}
问题是,我在我的段落中收到了这个:
<To href="">Contact Us</a>
(没有空格,因为堆栈溢出正在正确解析 html)。
我错过了什么?
慕的地6264312
相关分类