复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46//1:输出简单的文本内容 public ActionResult ContentText() { string content = "<h1>欢迎你的到来</h1>"; return Content(content); } //2:输出JSON 字符串 public ActionResult JsonTest() { var book = new { bookId = 1, bookName = "动态网站", autho = "老师" }; return Json(book,JsonRequestBehavior.AllowGet); } //3:输出JavaScript文件 public ActionResult JavaScriptTest() { string js = "alert('欢迎你的到来')"; return JavaScript(js); } //4:重定向页面跳转 public ActionResult RedirectTest() { return Redirect("/Home/Index"); } //5:跳转到指定的Action(也可以到其它控制器) public ActionResult RedirectToActionTest() { return RedirectToAction("Detail", new { id = 1,cate="test" }); } //6:返回一个视图 public ActionResult Index() { return View(); }
最后
以上就是文艺流沙最近收集整理的关于MVC 中控制器的返回值的全部内容,更多相关MVC内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复