Asp.net mvc 3 asp.net mvc找不到默认操作
对不起我的英语如果不是这样的话,我希望你能理解我 出现问题,找不到默认操作 Asp.NETMVC3中的项目。 我有一个包含动作索引的控制器。 在global.asax中拼写标准代码Asp.net mvc 3 asp.net mvc找不到默认操作,asp.net-mvc-3,Asp.net Mvc 3,对不起我的英语如果不是这样的话,我希望你能理解我 出现问题,找不到默认操作 Asp.NETMVC3中的项目。 我有一个包含动作索引的控制器。 在global.asax中拼写标准代码 routes.MapRoute ( "Default", / / Route name "{controller} / {action} / {id}", / / URL with parameters new {controller = "Home", action = "Index", id = U
routes.MapRoute (
"Default", / / Route name
"{controller} / {action} / {id}", / / URL with parameters
new {controller = "Home", action = "Index", id = UrlParameter.Optional} / / Parameter defaults
);
在HomeController中,我执行以下操作
return RedirectToAction ("index", "contest");
竞赛管理员
public class ContestController : BaseController
{
public ActionResult Index()
{
// Code
return View();
}
public ActionResult VoteFor(int id)
{
//code
return View();
}
[HttpPost]
public ActionResult SaveContest(int id)
{
// code
return RedirectToAction("Index");
}
public ActionResult ResultVoting()
{
//code
return View();
}
[HttpPost]
public ActionResult SetLocale()
{
int localeId;
if(int.TryParse(Request.Params["fieldId"], out localeId))
{
this.UserResults.SetLocaleId(localeId);
}
return RedirectToAction("index", "contest");
}
}
在地址栏中,仅显示localhost/contest
并最终导致404错误页面未找到。
如果手动附加localhost/contest/索引
一切都很好。
虽然最近一切都很好,但旧的回滚更改不起作用=(
你能告诉我有什么问题吗
我在主控制器的作用下调用重定向
public class ContestController : BaseController
{
public ActionResult Index()
{
// Code
return View();
}
public ActionResult VoteFor(int id)
{
//code
return View();
}
[HttpPost]
public ActionResult SaveContest(int id)
{
// code
return RedirectToAction("Index");
}
public ActionResult ResultVoting()
{
//code
return View();
}
[HttpPost]
public ActionResult SetLocale()
{
int localeId;
if(int.TryParse(Request.Params["fieldId"], out localeId))
{
this.UserResults.SetLocaleId(localeId);
}
return RedirectToAction("index", "contest");
}
你能把
ContestController
当你执行返回重定向到操作(“索引”,“竞赛”)时发生的事情的签名包括在内吗?
当我执行重定向时,我认为它应该进入索引。我设置了断点,但它没有进入。你在哪里调用返回重定向到操作(“索引”,“竞赛”)
?是否处于主控制器的索引操作中?