MVC 接收参数时会自动解码

MVC在接收传递过来的参数时,会自动对参数进行解码,无需手动解码

例:

public ActionResult SendMsg2(string name)
{
return Content(name);
}
public ActionResult SendMsg1()
{
return Content(Url.Encode("大家好"));
}

首先执行SendMsg1 方法,获取到“大家好”的编码,然后复制编码。

然后执行SendMsg2 方法,并将编码当做参数传递,则SendMsg2执行结果显示为:”大家好“

原文地址:https://www.cnblogs.com/gavin-num1/p/4819665.html