0

I am getting an error on a web site deployed on client machines. At first I thought it was caused by Windows authentication and multiple error providers as per my answer to the question here. But I have added Elmah to do logging on the client and am noticing a pattern....

The controller signature is:

public ActionResult Class(int subjectId, int classGroupId)

The request that is failing is listed in the elmah log:

HTTP_REFERER - https://someUrl.com/Results/Class/4372/16202

however the path info only has one parameter.

PATH_INFO - /Results/Class/4372/

The error message is

System.ArgumentException The parameters dictionary contains a null entry for parameter 'subjectId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Class(Int32, Int32)' in 'MyNamespace.Controllers.ResultsController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters

So somewhere along the line I am losing a parameter. Curious that the error message says the first parameter is missing and not the second.

I have a route set up for this action:

 routes.MapRoute(
     "ClassResults", // Route name
     "{controller}/{action}/{subjectId}/{classGroupId}", // URL with parameters
     new { controller = "Results", action = "Class" } // Parameter defaults
 );

How can I debug this error, what should I be looking at to determine what the issue is?

Community
  • 1
  • 1
Aran Mulholland
  • 23,555
  • 29
  • 141
  • 228
  • 1
    The ordering of your routes is important, perhaps this route is below the default route and therefore not being used? It is possible that it just says the first is missing and not the second because it didn't actually bother checking the second as the first failed – David Esteves Nov 26 '12 at 05:10
  • Show please your all route configuration, because may be you have other route before route which you specified here, and it route may be executed. – testCoder Nov 26 '12 at 05:44
  • Could it be that the controller action is called "Class"? – Aran Mulholland Nov 26 '12 at 06:07

0 Answers0