Public action method 'Index' was not found on controller in mvc 5
I m using log4net to log any exceptions. On the live website log file we are getting this error almost every min
System.Web.HttpException (0x80004005): A public action method 'Index' was not found on controller 'xxx.WebUI.Controllers.HomeController'
The Index method is there in controller with the action filter [HttpGet]
and the post method has filters [HttpPost] [ValidateAntiForgeryToken]
. All is working fine in the browsers. Any ideas why it would be showing in logs?
The code for the controller looks like
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);
}
And the full error is like below
2015-05-20 00:00:19,838 3290127 ERROR 5 WebUILogger:
User: System.Web.HttpException (0x80004005): A public action method 'Index' was not found on controller 'xxxx.WebUI.Controllers.HomeController'. at 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) at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid<>.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult, ProcessRequestState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
上一篇: 使用Async时超时