Using asp.net Mvc3 RTM, IIS7.
I'm getting flooded with errors like this one:
System.Web.HttpException
A public action method 'Application' was not found on controller 'Interreg.Web.Controllers.ApplicationsController'.
System.Web.HttpException (0x80004005): A public action method 'Application' was not found on controller 'Interreg.Web.Controllers.ApplicationsController'.
at System.Web.Mvc.Controller.HandleUnknownAction(String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
at System.Web.Mvc.MvcHandler.<>c_DisplayClass6.<>c_DisplayClassb.b_5()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c_DisplayClass1.b_0()
at System.Web.Mvc.Async.AsyncResultWrapper>
c_DisplayClass8'1.BeginSynchronous>b__7(IAsyncResult )
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.MvcHandler.<>c_DisplayClasse.b_d()
at System.Web.Mvc.SecurityUtil.b_0(Action f)
at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Controllers and actions changes, they surely do exist and app does not crash - user does not see yellow screen of death.
I suspect it has something to do with static resource loading (images, scripts), probably routing.
Any ideas what's wrong, what can cause this?
It may be what you say. I'd suggest to check IIS log for queries against /Application to see where is that URL and where it's called.
Another option is navigating while in debug mode and in that case exception should pause the execution in Visual Studio.
Good luck!
Verify the type of request.(Either GET or POST)
Add [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)] attributes at above the method
If Application method was returning the Json result add JsonRequestBehavior.AllowGet behavior in return Json.
Eg: return Json(zeroResult, JsonRequestBehavior.AllowGet);
Related
Maday,
i'm getting this error logged in db any idea or clue to fix this intermittent asp.net mvc exception.
thanks
Unhandled System.Web.HttpException (0x80004005): A public action method 'undefined' was not found on controller '#######'.
at System.Web.Mvc.Controller.HandleUnknownAction(String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__4()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) at System.Web.Mvc.Controller.HandleUnknownAction(String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__4()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I can't say for sure, but I suspect this is the result of a URL being constructed in JavaScript where a variable is not being defined.
Something like:
var action
var url = '/myContoller/' + action
This will result in a request to:
/myContoller/undefined
The intended URL could be for something that isn't even intended to be an MVC route. It could be for an image or something.
var imageUrl
var url = '/folder/' + imageUrl
/myFolder/undefined
MVC will try to route that, depending on how your routing is configured.
Is there any information in your logs about where the requests are coming from?
Update 1:
If you want MVC to ignore all requests to a particular area of your site (images directory for example), you can do something like this:
routes.IgnoreRoute("images/{*pathinfo}");
I have discerned a possible way to fix the image URL routing problem, based on #Dan's helpful answer:
So, because I have this "catch-all" route for 404 errors in my RouteConfig.cs:
// for 404-error page routing
routes.MapRoute(
name: "Error",
url: "{*url}",
defaults: new { controller = "Error", action = "PageNotFound" }
);
...MVC is oddly interpreting images that I have loaded via a Razor #foreach statement as URL's:
// this is triggering the weird problem, dunno why:
#foreach (string image in this.Model.ImageArray)
{
<img src="#this.Url.Content(image)" title="foobar" alt="#image" />
}
The Exception type is HttpException and the Exception message generated is:
A public action method '[object HTMLImageElement]' was not found on controller 'MyWebsite.Controllers.HomeController'
Placing routes.IgnoreRoute("MyImageFolderPath/{*pathinfo}"); at the top of the RegisterRoutes method in my RouteConfig.cs did not resolve this issue, but this did:
routes.IgnoreRoute("[object HTMLImageElement]");
It still seems hackish though, and due to my poor implementation of handling 404-errors...
You can verify that it works though by sprinkling breakpoints throughout your RouteConfig.cs, and also in the Application_Error method in Global.asax.cs (if you are also handling HttpException errors there).
I am getting A public action method 'cache' was not found on controller occasionally while executing the actionresult. Although here is no cache defined or used in my code.Don't know where from it is getting this. it is happening on telerik mvc grid's ajax binding. Here is the stack trace from elmah
HTTP Referrer
/mycontroller/75/myaction
Path Info
/mycontroller/cache/b19858cce4adf72d090c2334d5584f06
StackTrace
System.Web.HttpException (0x80004005): A public action method 'cache' was not found on controller 'myapp.Controllers.MyController'.
at System.Web.Mvc.Controller.HandleUnknownAction(String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
There is a Chrome bug that matches this description: http://code.google.com/p/chromium/issues/detail?id=132059
According to the issue description it does not occur with other browsers so it is very likely that Chrome has to do something with it. However, the bug is not confirmed yet and there are multiple theories what might cause it. I would suggest that you test with multiple browsers yourself to check if it is related to Chrome.
So we keep getting this error:
System.InvalidOperationException: The view 'Error' or its master was not found. The following locations were searched:
~/Views/Indications/Error.aspx
~/Views/Indications/Error.ascx
~/Views/Shared/Error.aspx
~/Views/Shared/Error.ascx
at System.Web.Mvc.ViewResult.FindView(ControllerContext context)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.b__4()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.b__0()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
when doing a multitude of things. It happens randomly, and sometimes happens doing the same exact thing that we just did without an error. Even when we catch an error in javascript sometimes, it still throws this error on the backend. Sometimes it navigates the user to a generic "Server Error" page as well.
What is a way we can handle this and display some information about the source of the issue? This stack isn't showing much...
Does your action method (or controller) has the [HandleError] attribute set on it? If that's the case and you don't have Error.aspx, then you will see this error. If you remove the [HandleError] attribute, you will be able to see the actual error.
how can I handle exception that is thrown in NHibernate method Flush? I have a action for deleting objects. It loads the objects from repository using posted ids and calls repository.Delete(obj).
Leaving aside that my mapping in NHibernate is not complete and the delete results in "The DELETE statement conflicted with REFERENCE constraint" exception, this is good case to implement the exception hadling for this case.
So the exception is thrown in Flush and the Flush is called in UnitOfWorkPerRequestTask, which is task created and destroyed on every request and it starts and flushes the UnitOfWork (Rhino.Commons.UnitOfWork). This task is registered using Windsor container and LifestyleType.Transient and it is called by HttpApplication inside Begin and EndRequest methods.
Is there any way how to handle this exception in my delete action, so I can notice user that this object cannot be deleted because of some relationships?
The exception stack trace is here (not full):
NHibernate.Transaction.AdoTransaction.Commit() +212
Rhino.Commons.NHibernateTransactionAdapter.Commit() +33
Rhino.Commons.BaseUnitOfWorkFactory.TransactionalFlush(IsolationLevel isolationLevel) +116
Rhino.Commons.BaseUnitOfWorkFactory.TransactionalFlush() +35
Cereal.Mvc.DataModule.Tasks.UnitOfWorkPerRequestTask.DisposeCore() in C:\projects\Sample\Cereal.Mvc.DataModule\Tasks\UnitOfWorkPerRequestTask.cs:33
System.Web.Mvc.Extensibility.Disposable.Dispose(Boolean disposing) in C:\projects\System.Web.Mvc.Extensibility\Abstraction\Disposable.cs:52
System.Web.Mvc.Extensibility.Disposable.Dispose() in C:\projects\System.Web.Mvc.Extensibility\Abstraction\Disposable.cs:35
Castle.MicroKernel.LifecycleConcerns.DisposalConcern.Apply(ComponentModel model, Object component) +47
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.ApplyConcerns(Object[] steps, Object instance) +129
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.ApplyDecommissionConcerns(Object instance) +106
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalDestroy(Object instance) +37
Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Destroy(Object instance) +37
Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Release(Object instance) +48
Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleManager.Evict(Object instance) +38
Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule.Application_EndRequest(Object sender, EventArgs e) +305
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Thanks for help.
If you call Flush() in a UnitOfWork, you can only catch the error and log it.
If you want your users inform about the error, then close the transaction or do the Flush earlierer (as stated in the comments of Paco and cbp). One place is to handle it in your action method. Check the outcome and report it to the user with an error page.
I have this simple controller:
public class OneController : Controller
{
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Create()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(IList<TestModel> m)
{
return View(m);
}
}
And a very simple view with two objects of type TestModel, properly indexed.
When I submit the form with invalid data, I get the view with the errors highlighted.
However, when I re-submit it (without changing anything), I get this error:
[NullReferenceException: Object reference not set to an instance of an
object.]
System.Web.Mvc.DefaultModelBinder.UpdateCollection(ModelBindingContext
bindingContext, Type itemType) +612
System.Web.Mvc.DefaultModelBinder.BindModelCore(ModelBindingContext
bindingContext) +519
System.Web.Mvc.DefaultModelBinder.BindModel(ModelBindingContext
bindingContext) +829
System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ParameterInfo
parameterInfo) +313
System.Web.Mvc.ControllerActionInvoker.GetParameterValues(MethodInfo
methodInfo) +399
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
controllerContext, String actionName)
+232
System.Web.Mvc.Controller.ExecuteCore()
+152
System.Web.Mvc.ControllerBase.Execute(RequestContext
requestContext) +86
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext
requestContext) +28
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase
httpContext) +332
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext
httpContext) +55
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext
httpContext) +28
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+358
System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously)
+64
Any idea on how can I debug this?
I was already looking at that article, and found the bug I was having (subtle, yet critical).
If you render the hidden field with the index using Html.Hidden, the helper will "accumulate" the previous values, so you'll end up with a hidden saying index=1, and the next saying index=1,2.
Changing the helper call to a manually coded hidden field fixed the issue.
Not sure I can answer without seeing more of the code and how your form is setup.
But, you could take a look at Phil Haack's blog entry about Model Binding To A List.Hope this helps.
Thanks that fixed it!
I replaced
<%= Html.Hidden("submitFormFields.index", controlID) %>
with
<input type="hidden" id="submitFormFields.index" name="submitFormFields.index" value="<%=controlID %>" />
Should we report this as a bug - It would be nice to have it fixed for ASP.Net MVC RC1