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).
Related
I'm trying to use Google OpenID with an MVC 4 app hosted on Azure & it keeps failing. Not straight away though. When I deploy the app, it all works perfectly time after time. I then leave it for some amount of time, usually a day, but could be an hour & then try again & it fails everytime. You then refresh, go back to the homepage, which sends you to the login page & it works again.
the error is :
[InvalidOperationException: Sequence contains no elements]
System.Linq.Enumerable.First(IEnumerable`1 source) +498
DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) +106
[ProtocolException: No OpenID endpoint found.]
DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) +303
Tools.Helpers.GoogleApps.Login(Uri returnUrl) in c:\Users\Simon\Documents\Visual Studio 2012\Projects\Internal Utils\Website\Helpers\GoogleApps.cs:33
Tools.Helpers.ExternalLoginResult.ExecuteResult(ControllerContext context) in c:\Users\Simon\Documents\Visual Studio 2012\Projects\Internal Utils\Website\Helpers\ExternalLoginResult.cs:25
System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +33
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +613
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +263
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +230
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +28
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
My code that triggers the request is:
//constructor
static GoogleApps()
{
var googleAppDiscovery = new HostMetaDiscoveryService
{
UseGoogleHostedHostMeta = true,
};
RelyingParty = new OpenIdRelyingParty();
RelyingParty.DiscoveryServices.Insert(0, googleAppDiscovery);
}
public void Login(Uri returnUrl)
{
var realm = new Realm(returnUrl.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped));
var request = RelyingParty.CreateRequest("my.domain.name", realm, returnUrl);
var fetch = new FetchRequest();
fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email, true));
fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Name.First, true));
fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Name.Last, true));
request.AddExtension(fetch);
request.RedirectToProvider();
}
I have not added anything extra to the web.config, other than the proxy config settings recommended elsewhere. Doesn't seem to make any difference.
<defaultProxy enabled="true">
<proxy autoDetect="True" usesystemdefault="True" />
</defaultProxy>
I'm using the latest 4.2.2 packages from nuget.
So it looks like by increasing the timeouts made it work, as suggested here. I set my values higher as suggested, but obviously you can test for the most appropriate values.
I also changed my code. You'll notice above the class contains a static variable for the replying party. I changed this to be an instance variable as I could see no reason to use this pattern. The sample code for DotNetOpenAuth doesn't use static instances for the Replying Party class either.
Unless anyone can suggest why having it as a static might be a good idea, I'll leave it as is.
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.
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);
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.
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