I have a nuget package which contains an MVC controller - MyController which has a method MethodWithStringParameter(string a) and another method MethodWithoutParameters().
I have installed this nuget package in my MVC service and have registered the controller and the routes.
public sealed class MyController : Controller
{
[System.Web.Mvc.HttpPost]
public HttpResponseMessage MethodWithStringParameter(string a)
{
return new HttpResponseMessage
{
StatusCode = HttpStatusCode.OK
};
}
[System.Web.Mvc.HttpPost]
public HttpResponseMessage MethodWithoutParameters()
{
return new HttpResponseMessage
{
StatusCode = HttpStatusCode.OK
};
}
}
When I try hitting MethodWithStringParameter method, I get an exception
Invalid JSON primitive: a.
However, I am able to hit the method MethodWithoutParameters without any issues.
Detailed exception
Type: "System.ArgumentException"
Message: "Invalid JSON primitive: a."
StackTrace: " at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) at System.Web.Mvc.JsonValueProviderFactory.GetValueProvider(ControllerContext controllerContext) at System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider(ControllerContext controllerContext) at System.Web.Mvc.ControllerBase.get_ValueProvider() at System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) at System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.b__19(AsyncCallback asyncCallback, Object asyncState)"