我收到一个间歇性异常,说asp.net mvc无法找到该操作方法。这是例外:
在控制器“ Schoon.Form.Web.Controllers.ChrisController”上找不到公共操作方法“填充”。
我认为我已经正确设置了路由,因为该应用程序大多数时候都可以工作。这是控制器的动作方法。
[ActionName("Fill")]
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post), UserIdFilter, DTOFilter]
public ActionResult Fill(int userId, int subscriberId, DisplayMode? mode)
{
//…
}
路线:
routes.MapRoute(
"SchoonForm",
"Form/Fill/{subscriberId}",
new { controller = "ChrisController", action = "Fill" },
new { subscriberId = @"\d+" }
);
这是堆栈:
System.Web.HttpException:在控制器“ Schoon.Form.Web.Controllers.ChrisController”上找不到公共操作方法“ Fill”。在System.Web.Mvc.Controller.ExecuteCore()处位于System.Web.Mvc.Controller.HandleUnknownAction(String actionName)在C:\ dev \ ThirdParty \ MvcDev \ src \ SystemWebMvc \ Mvc \ Controller.cs:line 197 :\ dev \ ThirdParty \ MvcDev \ src \ SystemWebMvc \ Mvc \ Controller.cs:C:\ dev \ ThirdParty \ MvcDev \ src \ SystemWebMvc \ Mvc \中System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)的第164行C. \ dev \ ThirdParty \ MvcDev \ src \ SystemWebMvc \ Mvc \ ControllerBase.cs:第87行中System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)处的ControllerBase.cs:第76行在System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext)中:
这是我的过滤器的示例,它们都以相同的方式工作:
public class UserIdFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
const string Key = "userId";
if (filterContext.ActionParameters.ContainsKey(Key))
{
filterContext.ActionParameters[Key] = // get the user id from session or cookie
}
base.OnActionExecuting(filterContext);
}
}
谢谢克里斯