A public action method 'cache' was not found on controller - asp.net-mvc

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.

Related

A public action method 'undefined' was not found on controller '#######'

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).

Google OpenID provider consistently fails on Azure

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.

EF4 trying to re-create database even though it's already there?

I'm using ASP.NET MVC 3 and have learnt through the MVC Music Store and other sources. I was able to create a database and have it live but the weird thing was about 5 hours after it was live it went down and had the following error and stack trace:
Note: This also seems to be the case whenever I publish the site. I have to go and delete the database manually for it to re create it and then it will work. But now that I'm live I can't do that because data is already being stored in there that I don't want to redo.
File already exists. Try using a different database name. [ File name = C:\HostingSpaces\...\wwwroot\App_Data\Test.sdf ]
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlServerCe.SqlCeException: File already exists. Try using a different database name. [ File name = C:\HostingSpaces\mtnp55\pricexperience.com\wwwroot\App_Data\Test.sdf ]
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlCeException (0x80004005): File already exists. Try using a different database name. [ File name = C:\HostingSpaces\...\wwwroot\App_Data\Test.sdf ]]
System.Data.SqlServerCe.SqlCeEngine.ProcessResults(IntPtr pError, Int32 hr) +72
System.Data.SqlServerCe.SqlCeEngine.CreateDatabase() +658
System.Data.SqlServerCe.SqlCeProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 timeOut, StoreItemCollection storeItemCollection) +194
System.Data.Objects.ObjectContext.CreateDatabase() +84
System.Data.Entity.Internal.DatabaseOperations.Create(ObjectContext objectContext) +8
System.Data.Entity.Database.Create() +76
System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context) +387
System.Data.Entity.<>c__DisplayClass2`1.<SetInitializerInternal>b__0(DbContext c) +75
System.Data.Entity.Internal.<>c__DisplayClass5.<PerformDatabaseInitialization>b__3() +19
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +72
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +169
System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) +7
System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +118
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +190
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +73
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +28
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +62
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +37
System.Linq.Queryable.Where(IQueryable`1 source, Expression`1 predicate) +63
PriceXperience.Controllers.AppsController.ViewLeaderboards(Int32 gameId) in C:\Users\Public\Documents\Development\...\Controllers\AppsController.cs:42
lambda_method(Closure , ControllerBase , Object[] ) +101
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
I've tried many things but still cannot figure out why it does this. I do have a database initialize.
System.Data.Entity.Database.SetInitializer<MobileEntities>(new SampleData());
public class SampleData : CreateDatabaseIfNotExists<MobileEntities>
The code that runs when I try to access the db is the following:
public ActionResult ViewLeaderboards(int gameId)
{
var leaderboards = from u in mobileDB.Scores
where u.GameId == gameId
select u;
return View(leaderboards.OrderByDescending(u => u.Score).ToList());
}
When publishing you need to be sure to REMOVE the Initializer from the Global.asax. The Initializer is only for populating test data, and should not be in use during production. I also remember reading somewhere that setting the Initializer to null might work.
Database.SetInitializer<MyContext>(null);
Or just comment out the line where you call SetInitializer before publishing. I also exclude my Initializer class from the project before publishing.
The default strategy for Code First contexts is an instance of CreateDatabaseIfNotExists.
So it is necessary to include the
Database.SetInitializer<MyContext>(null);
so that the default initializer is not called which might then give an error!
Also, it is necessary to include the generic tag when setting it to null or the compiler will give an error.

Strange asp.net mvc error

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);

Error in ASP.NET MVC Application

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.

Resources