asp.net mvc 返回字符串的动作编码tip

public string Welcome(string name, int ID = 1)
{
    return HttpUtility.HtmlEncode("Hello " + name + ", ID: " + ID);
}

public string Welcome(string name, int numTimes = 1) {
     return HttpUtility.HtmlEncode("Hello " + name + ", NumTimes is: " + numTimes);
}
尽量采用HttpUtility.Encode 和HttpUtility.Decode方法,防止乱码等情况
posted @ 2015-03-31 10:08  ip8888  阅读(205)  评论(0编辑  收藏  举报