Skip to content

[Audited] on controller methods with nullable parameters #2355

@worthy7

Description

@worthy7

When using the [Audited] attribute on ANY methods in a controller which has a method with some nullable parameters, an error is thrown when said method is called.

Example

[Audited]
public virtual ActionResult a(){return whatever}

public virtual ActionResult b(int? shipHighlightGreen = null)
{ 
return whatever
}

goto: www.mywebsite.com/controller/b

Error will be thrown - even though method b does not even have the attribute on it.

ERROR 2017-07-25 12:12:51,452 [51   ] MyProject.Web.Controllers.OrderController   - The parameters dictionary contains an invalid entry for parameter 'shiphighlightGreen' for method 'System.Web.Mvc.ActionResult Modal_Order_Details(Int32, Boolean, System.Nullable`1[System.Int32], System.Nullable`1[System.Int32])' in 'Castle.Proxies.OrderControllerProxy'. The dictionary contains a value of type 'System.Reflection.Missing', but the parameter requires a value of type 'System.Nullable`1[System.Int32]'.
ParameterName:parameters
System.ArgumentException: The parameters dictionary contains an invalid entry for parameter 'shiphighlightGreen' for method 'System.Web.Mvc.ActionResult Modal_Order_Details(Int32, Boolean, System.Nullable`1[System.Int32], System.Nullable`1[System.Int32])' in 'Castle.Proxies.OrderControllerProxy'. The dictionary contains a value of type 'System.Reflection.Missing', but the parameter requires a value of type 'System.Nullable`1[System.Int32]'.
ParameterName:parameters
   Location System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo parameterInfo, IDictionary`2 parameters, MethodInfo methodInfo)
   Location System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   Location System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   Location System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   Location System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   Location System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   Location System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   Location System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   Location System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   Location System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   Location System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   Location System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   Location System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult)
   Location System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   Location System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   Location System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
   Location System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   Location System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

if it's

public virtual ActionResult b(int shipHighlightGreen = -1)
{ 
return whatever
}

It works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions