您的位置:首页 > 其它

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