您的位置:首页 > 编程语言 > C#

C# MVC跳转

2016-04-24 19:56 316 查看
MVC方式:

RedirectToAction(view?参数,控制器);

return RedirectToAction("Index?id=" + eventid + "&type=6", "Event");


显示提示框,并返回上一页

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>");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: