mvc 使用response.redirect跳转地址问题
2015-03-23 17:37
295 查看
我在项目中使用了个personTemplateController继承父类PersonSiteBaseController.cs文件,然后我在PersonSiteBaseController文件里头判断了传入的参数,数据库找不到记录我就直接跳转到首页,使用reponse.redirect命令进行地址跳转,但是却提示了如下错误:
语句:
public class PersonTemplateController : PersonSiteBaseController{
}
父类文件:
public class PersonSiteBaseController : Controller
{
//
// GET: /PsersonSiteBase/
public PersonSiteBaseController()
{
string userpycode = System.Web.HttpContext.Current.Request.RequestContext.RouteData.Values["userpycode"] as string;
.......
else
{
Response.Redirect("/law");
}
后来咨询了下前辈,说是在继承的父类中不能直接使用request或者是response简写命令,必须完整的空间命名等都带入才可以,具体如下:
System.Web.HttpContext.Current.Response.Redirect("/law");
语句:
public class PersonTemplateController : PersonSiteBaseController{
}
父类文件:
public class PersonSiteBaseController : Controller
{
//
// GET: /PsersonSiteBase/
public PersonSiteBaseController()
{
string userpycode = System.Web.HttpContext.Current.Request.RequestContext.RouteData.Values["userpycode"] as string;
.......
else
{
Response.Redirect("/law");
}
后来咨询了下前辈,说是在继承的父类中不能直接使用request或者是response简写命令,必须完整的空间命名等都带入才可以,具体如下:
System.Web.HttpContext.Current.Response.Redirect("/law");
相关文章推荐
- 使用Response.Redirect跳转时显示提示内容的问题该怎么解决
- asp.net mvc中在Filter中跳转千万不要使用Response.Redirect
- asp.net mvc中在Filter中跳转千万不要使用Response.Redirect[转]
- mvc中用response.redirect跳转后,后续代码还会执行的问题
- 在MVC里面使用Response.Redirect方法后记得返回EmptyResult
- 在MVC里面使用Response.Redirect方法后记得返回EmptyResult
- 使用springmvc redirect跳转地址时中文参数为空
- 在线聊天项目1.4版 使用Gson方法解析Json字符串以便重构request和response的各种请求和响应 解决聊天不畅问题 Gson包下载地址
- 在线聊天项目1.4版 使用Gson方法解析Json字符串以便重构request和response的各种请求和响应 解决聊天不畅问题 Gson包下载地址
- 使用response.sendirect("html/employee.html?"+java.net.URLEncoder.encode(param.substri) 重定向传递参数,并隐藏跳转地址
- 关于ASP.NET MVC中Response.Redirect和RedirectToAction的BUG (跳转后继续执行后面代码而不结束进程)以及处理方法
- Spring3 MVC使用@ResponseBody的乱码问题及解决办法
- Spring3 MVC使用@ResponseBody的乱码问题及解决办法
- Spring3 MVC使用@ResponseBody的乱码问题及解决办法
- 高效的使用 Response.Redirect解决一些不必要的问题
- 求解,ASP.Net MVC Redirect 无法跳转问题
- ASP.NET MVC- 在Area里使用RedirectToAction跳转出错的解决方法
- 高效的使用Response.Redirect解决一些不必要的问题(转载)
- 关于 context.Response.Redirect 跳转问题 .