MVC 中用JS跳转窗体Window.Location.href

一般的Window.Location.href会造成URL地址追加

较为好的写法为:

return Content(string.Format("<script type='text/javascript'>alert('请先维护实验前提条件!');window.location.href='{0}'</script>", Url.Action("OfflineLab", "OfflineLab", new { labType = Server.UrlEncode(topic), conditionDesc = unit })));

①要是有中文参数的话,需要加 Server.UrlEncode(中文参数)传递到控制器的action中;

②接收中文参数的话,则为  string   labType = Server.UrlDecode(labType);

原文地址:https://www.cnblogs.com/changbaishan/p/15641400.html