ASP.NET MVC3中文参数乱码问题

2025-05-19 18:17:04
推荐回答(4个)
回答1:

编码后 常理来说 是不会乱码的

注意   你R["IG_Name"] 取值 之后 是否 已乱码 


    

public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            return View();
        }

public ActionResult IndexTwo()
        {
            ViewData["IG_Name"] = Request["IG_Name"];
            return View();
        }

    }

Index.aspx

    

        ">Click Me
    



IndexTwo.aspx
 
    

        <%=ViewData["IG_Name"] %>
    

回答2:

后台:

Server.HtmlEncode(msg)

前台:
Server.HtmlDecode(msg)

回答3:

  1. 编码都换UTF-8试试

  2. 换个传参方式,用表单+POST传

回答4:

有没有试过对<%= R["IG_Name"]%>进行URL编码?