2

I've been working on an MVC 5 project for a while now. I left the office yesterday evening with it functioning fine (local and on the web), and this morning all of a sudden it is throwing an exception that is being caught by my Application_Error() method in the Global.asax file on startup saying it can't find a public ActionResult on my controller:

enter image description here

And here is a snap of my controller:

enter image description here

As you can see I am using AttributeRouting which I have had absolutely zero problems until this morning. I have the routes.MapMvcAttributeRoutes(); in the proper location within the RegisterRoutes() method.

Zero changes were made to my code overnight (I utilize source control) and I am the only one with access to the dev machine and the repository.

When I am stepping through starting at Application_Start() in Global.asax, it successfully gets to the end of the method and then throws the ActionResult not found error. The StackTrace gives me nothing useful...I am unsure of what to do now.

Has anyone experienced an anomaly like this or have any ideas of what I can try to get my project running again? Once again, I made no changes to the code between yesterday evening and this morning.


EDIT

Now it is working...I made no changes to the code. I've been fighting with this thing for almost 2 hours and it just decides to start working again. Gotta love programming.

Community
  • 1
  • 1
Anders
  • 12,088
  • 34
  • 98
  • 146
  • Just double checking, you are running HTTPS when testing? – Joachim Isaksson Feb 02 '16 at 15:59
  • Yes, in the project properties "SSL Enabled" is set to true. – Anders Feb 02 '16 at 16:01
  • Yes, that's why I'm asking. Had similar trouble with RequireHttps when the site was unexpectedly accessed via http so wanted to make sure. – Joachim Isaksson Feb 02 '16 at 16:02
  • I have a feeling the AttributeRouting got messed up somehow...but I am unsure as to how it could have since there were no changes made to the code. – Anders Feb 02 '16 at 16:03
  • By any chance, do you have the same class/controller name more than once (in different namespaces)? This error just sounds very similar to what I was dealing with: http://stackoverflow.com/questions/34425180/attribute-routes-missing-from-routing-table-when-using-multiple-namespaces – GendoIkari Feb 02 '16 at 16:25
  • @Gendolkari -- No, I decorated the old Home controller with a unique RoutePrefix. Anyway, it seems to be a phantom was haunting my project...it is working fine now with no changes made by me. No idea what the cause was, nor how it got resolved, unfortunately. – Anders Feb 02 '16 at 16:27

1 Answers1

0

Yep this kind of thing has happened to me...

I have a Controller called "AdminController", it's been working fine for literally 3 years. Recently, 1 or 2 of the ActionResults inside this Controller can randomly no longer be found. One of them is called "Categories". I.e. /Admin/Categories. If I now hit that Url, the whole app simply redirects back to the home page / root Url and the "Categories" actionresult method is never ever hit in the debugger.

This behaviour is the same both in my Visual Studio dev instance as well as when I publish the site to Azure. So at least it's not just isolated to the web server..

I've looked at all my defined Routes and disabled them, but to no avail. I've also overridden the Init method inside Global.asax and again it finds my Categories method, but then later redirects to the home page root Url for some reason!

Absolutely no idea what is causing this...

Aaron
  • 1,802
  • 3
  • 23
  • 50