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文件我在这 ...
随机推荐
- js获取当前的时间(包含星期)
<script type="text/javascript"> setInterval("www_zzje_net.innerHTML=new ...
- ORA-04021
编译或删除存储过程的时候,系统会卡住,一段时间后出现ora-04021错误. 1.可能被锁住查看v$locked select b.sid,b.serial#,b.machine,b.terminal ...
- scala学习笔记——类和对象
基础语法关于Scala程序,这是非常要注意以下几点. 区分大小写 - Scala是大小写敏感的,这意味着标识Hello 和 hello在Scala中会有不同的含义. 类名 - 对于所有的类名的第一个字 ...
- easyui之datagrid(不定时补充)
1,datagrid之formatter formatter格式化函数有三个参数: value:字段值(一般为后台传递给前台的值): row:当前行数据: index:当前行索引. return值是显 ...
- 解决CentOS 5.8在虚拟机环境下如何桥接上网
1.虚拟机的网卡配置如下图所示: 2.在CentOS 5.8的命令行界面:输入如下指令 然后准备修改里面的网关地址和自己的IP地址 3.同时查看自己的IP地址和网关 4.在第二步里面修改,网关地址应该 ...
- Python同时向控制台和文件输出日志logging的方法 Python logging模块详解
Python同时向控制台和文件输出日志logging的方法http://www.jb51.net/article/66756.htm 1 #-*- coding:utf-8 -*- 2 import ...
- Win7下部署 .NET MVC网站 之 HTTP错误 403.14-Forbidden 解决方法
今天在 IIS 7 发布MVC 站点时 遇到 ”HTTP错误 403.14-Forbidden Web 服务器被配置为不列出此目录的内容 “ 的错误提示. 一番折腾后发现在web.config 中加入 ...
- 【Beta】Phylab2.0: Postmortem
设想和目标 1. 我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的描述? 主要解决同学们写物理实验报告时,处理数据的困难--巨大的计算量和不规范的物理报告数据处理格式.典型 ...
- 这样就算会了PHP么?-4
数组初步 <?php $ereg = 'tm'; $str = 'hello,tm,Tm,tM,TM.'; $rep_str = eregi_replace($ereg, 'TM', $str) ...
- bzoj1178
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1178 看ppt http://wenku.baidu.com/link?url=dJv6LNm ...