C# MVC跳轉


MVC方式:

顯示提示框,並返回上一頁

return Content("<script>alert('暫時沒有實踐作業!');history.go(-1);</script>");

Redirect("/控制器/視圖?參數");

return Redirect("/Home/Index?id=" + id + "&T=" + T + "");

RedirectToAction("視圖",new { 參數 });

return RedirectToAction("Index", new { type = 1 });

RedirectToAction(view?參數,控制器);

return RedirectToAction("Index?id=" + id + "&type=1", "Home");

當用Redirect或者RedirectToAction的時候,盡量使用false參數。在網頁瀏覽的時候,有可能因為沒有false導致網頁線程中斷。(猜測,沒證據)

return Response.Redirect(url1, false);
return RedirectToAction("Index", "Home", false);
return Redirect("/Index/Home");

return View()

//返回的是view頁面,不會再走Controller
return View("Index");

其他方式:

void情況的跳轉,可以在script里寫js跳轉

Response.Write("<script>alert('文件未占用或文件未生成,請稍后重試!');window.close(); </script>");

 


免責聲明!

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



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