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);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM