公共行为方法'索引'在mvc 5中没有在控制器上找到

我使用log4net记录任何异常。 在实时网站日志文件中,我们几乎每分钟都会收到此错误

System.Web.HttpException (0x80004005): A public action method 'Index' was not found on controller 'xxx.WebUI.Controllers.HomeController'

Index方法在控制器中使用动作过滤器[HttpGet] ,并且post方法具有过滤器[HttpPost] [ValidateAntiForgeryToken] 。 所有浏览器都能正常工作。 任何想法为什么它会显示在日志中?

控制器的代码如下所示

public class HomeController : Controller
{
    private readonly IProductService _productsService;
    private readonly IMappingEngine _mappingEngine;
    private readonly ILog _logger;

    public HomeController(IProductService _productsService, IMappingEngine mappingEngine, ILog logger)
    {
        _productsService= productsService;
        _mappingEngine = mappingEngine;
        _logger = logger;
    }

    [HttpGet]
    public ActionResult Index()
    {
        if (User.Identity.IsAuthenticated)
        {
            return RedirectToAction("RouteToHomePageByRole", "Account");
        }

        return View(new RegisterInterestModel());
    }

    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Index(RegisterInterestModel model)
    {
        try
        {

            if (ModelState.IsValid)
            {
                //some stuff
            }
        }
        catch (EntityValidationException ex)
        {
            // Validation errors
            foreach (var err in ex.ValidationErrors)
            {
                ModelState.AddModelError(err.PropertyName, err.Message);
            }
        }
        catch (Exception ex)
        {
            _logger.Error(ex);
            ViewBag.Error = true;
        }

        return View(model);
    }

完整的错误如下所示

2015-05-20 00:00:19,838 3290127错误5 WebUILogger:

用户:System.Web.HttpException(0x80004005):在控制器'xxxx.WebUI.Controllers.HomeController'上未找到公共操作方法'Index'。 System.Web.Mvc.Controller.HandleUnknownAction(String actionName)at System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult,ExecuteCoreState innerState)at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid <>。CallEndDelegate(IAsyncResult asyncResult )在System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid <>。System.Web.Mvc.MvcHandler.b__5上的CallEndDelegate(IAsyncResult asyncResult)(IAsyncResult asyncResult,ProcessRequestState innerState)在System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid` 1. System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()上的System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()在System上的CallEndDelegate(IAsyncResult asyncResult)。 Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔&完成同步)

链接地址: http://www.djcxy.com/p/85127.html

上一篇: Public action method 'Index' was not found on controller in mvc 5

下一篇: Not able to return CSV file in MVC action. Not Cannot access a closed Streamable