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方法,防止乱码等情况
原文地址:https://www.cnblogs.com/aobama/p/4380089.html