Action重定向总结
[HttpPost]
public ActionResult StudentList( string StudName, string studName, DateTime BirthDay, FormCollection form, string controller, string Action, StudentModels student)
{
//其中StudName为aspx页面中标签的name属性(StudName不区分大小写)
//其中BirthDay为页面中标签的name属性(类型可自己指定【需转换成功才可以】,这里为DateTime)同样BirthDay不区分大小写
//其中controller,Action为路由信息(controller,Action不区分大小写)
//FormCollection包含了post回来的信息 通过form[]来取值
//如果使用强类型绑定 可通过实体回传值 这里实体为StudentModels
//同样可以使用Request.Form[] Request.QueryString[] Request[] 来取值 不过此Request非WebForm中的Request 这里的Request是RequestBase抽象类的实例 WebForm中Request是封装类 HttpRequest的实例 #region 到要经过执行controller里方法后 显示出页面。
//return RedirectToAction("Index");//可跳出本controller
//return RedirectToRoute(new {controller="Home",action="Index"});//可跳出本controller
//Response.Redirect("Index");//只能使用本controller下的方法名称。返回值为void
//return Redirect("Index");//只能使用本controller下的方法名称。
#endregion #region 直接显示出对应的页面 不经过执行controller的方法。
//return View("Index");//被controller 的其他视图//return View("~/Views/Home/Index.aspx");//任意controller下的其他视图
#endregion
return View();
}
//重定向跳转 到指定视图
//1. 使用视图名称创建一个呈现视图的 System.Web.Mvc.ViewResult 对象。(不经过Action 方法)
return View("RedirectOne");
return View("~/Views/Two/RedirectOne.cshtml"); //重定向跳转 到本controller下的action
return Redirect("RedirectOne");
Response.Redirect("RedirectOne");
return null; //重定向跳转 到其他或本controller下的action
//本controller
return RedirectToAction("RedirectOne");
//其他controller
return RedirectToAction("MasterOne", "One");
//本controller
return RedirectToRoute(new { action = "RedirectOne" });
//其他controller
return RedirectToRoute(new { controller = "One", action = "MasterOne" });
//跨区域 重定向
//其他controller
return RedirectToAction("Index", "BlogIndex", new { area="Blog"});
return RedirectToRoute( new { area = "Blog" ,controller="BlogIndex",action="Index"});
4.加载其他视图的方式
//返回 其他的视图,不经过controller
//可以 传递 model 参数
public PartialViewResult PartialTwo()
{
List<string> list = new List<string>() {
"姓名",
"密码"
};
return PartialView(); return PartialView("PartialOne", list);//本controller 下的视图,带参数 return PartialView("~/Views/Redirect/PartialOne.cshtml", list);//其他controller 下的视图 带参数 return PartialView("~/Views/LayoutOne/PageOne.cshtml");//其他controller 下的视图
}
Action重定向总结的更多相关文章
- struts2 action重定向
struts2的结果类型: <action name="loginAction" class="com.itheima.action.LoginAction&quo ...
- ASP.Net MVC Action重定向跳出Controller和Area
1.重定向方法简介 [HttpPost] public ActionResult StudentList( string StudName, string studName, DateTime Bir ...
- struts2 action重定向action中文乱码处理
比如:Action方法productCategorySave()变量message,传递给Action方法productCategoryAdd(),当变量message为中文变量时,要进行编码设置,不 ...
- Asp.net Mvc Action重定向总结
摘自博客园 程晓晖 [HttpPost] public ActionResult StudentList( string StudName, string studName, DateT ...
- Struts1 action重定向跳转 带参数
ActionForward forward = new ActionForward("kmRentalMain.do?method=view&fdId="+id);forw ...
- 20SpringMvc_结果的转发可共享参数;重定向不能共享参数
Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE MicrosoftInternetExplorer4 /* Style Definiti ...
- struts2视频学习笔记 03-06(Struts 2配置文件无提示问题,Action配置中的各项默认值,各种转发类型)
课时3 解决Struts 2配置文件无提示问题(eclipse):window→preference→XML→XML Catlog
- Struts2之Action接收请求参数和拦截器
技术分析之在Struts2框架中使用Servlet的API 1. 在Action类中也可以获取到Servlet一些常用的API * 需求:提供JSP的表单页面的数据,在Ac ...
- Struts2中Action之ResultType
我们在struts-defalut.xml文件中可以看到如下图所示: 这些类型是配置文件所带的.接下来我们主要讲解我标注出来的这个,其他的我就不做详解了,有兴趣的可以去试试. web.xml文件我在这 ...
随机推荐
- SignalR2.0开发实例之——创建房间聊天
SignalR作为一个强大的集线器,已经在hub里面集成了Gorups,也就是分组管理,使用方法如下: //作用:将连接ID加入某个组 //Context.ConnectionId 连接ID,每个页面 ...
- ShopEx访问提示Incompatible file format: The encoded file has format major ID 2, whereas the Loader expects 4
今天测试了下ShopEx程序,但是ShopEx安装时(程序放在public_html目录下的test目录中)遇到了问题,提示错误如下:Fatal error: Incompatible file fo ...
- 解决IE10以下对象不支持“bind”属性或方法
IE10一下的浏览器,如果在JS代码中用了bind函数,那么就会报“SCRIPT438: 对象不支持“bind”属性或方法” 因为浏览器没有提供这个参数的方法,所以我们就自己写一个bind,来让这个参 ...
- Openjudge 百练第4109题
在OpenJudge看到一个题目(#4109),题目描述如下: 小明和小红去参加party.会场中总共有n个人,这些人中有的是朋友关系,有的则相互不认识.朋友关系是相互的,即如果A是B的朋友,那么B也 ...
- Javascript中的对象和原型
一 原型对象 原型对象实际上就是构造函数的一个实例对象,和普通的实例对象没有本质上的区别.可以包含特定类型的所有实例的共享属性或者方法.这样,如果我们需要修改所有实例中的属性或者方法,就只需要修改一处 ...
- nodejs javascript微信开发
1.当从第三方软件需要分享到微信的时候 需要给授权处理才能获得微信信息 比如 nickname 等昵称图像等 从第三方登陆跳转到微信分享页需要 shareurl = http://open.weixi ...
- UITableView常用属性和方法 - 永不退缩的小白菜
UITableView常用属性和方法 - 永不退缩的小白菜 时间 2014-05-27 01:21:00 博客园精华区原文 http://www.cnblogs.com/zhaofucheng11 ...
- cf C. Vasya and Robot
http://codeforces.com/contest/355/problem/C 枚举L和R相交的位置. #include <cstdio> #include <cstring ...
- FJ省队集训DAY4 T3
#include<cstdio> #include<iostream> #include<cmath> #include<cstring> #inclu ...
- CCI_chapter 3 Stacks and Queues
3.1Describe how you could use a single array to implement three stacks for stack 1, we will use [0, ...