Question

Please take a look at the following code. It's in handler.asxh.

public void ProcessRequest(HttpContext context)
{
    context.Response.ContentType = "application/json";
    new RequestManagementFacade().PinRequest(Int32.Parse(context.Request.QueryString["requestId"]), (Boolean.Parse(context.Request.QueryString["isPinned"])));
}

This is showing the following error:

Value cannot be null. Parameter name: String

There is value being passed as I have checked the context request query string, however, the code breaks at this stage.

This handler will connect to the business logic layer.

Était-ce utile?

La solution

There is value being passed as i have checke dthe context request query string

I strongly suspect your diagnostics are incorrect then. Values don't magically go missing - you need to question your assumptions. This is easy to debug through though. I would suggest changing your code to:

public void ProcessRequest(HttpContext context)
{
    context.Response.ContentType = "application/json";
    string requestId = context.Request.QueryString["requestId"];
    string isPinned = context.Request.QueryString["isPinned"];
    var facade = new RequestManagementFacade();
    facade.PinRequest(Int32.Parse(requestId), Boolean.Parse(isPinned));
}

It's then really simple to step through and find out what's going on.

Autres conseils

It is likely that either context.Request.QueryString["requestId"] or context.Request.QueryString["isPinned"] is not returning a valid string value. Check that both values are passed in the query string with the proper IDs, those being of course requestId and isPinned.

Okay solved when passing the values to the handler i inserted it as

"PinRequest.ashx?="+requestId+isPinned"

Which gave me the result 2True

So i realised the hiccup was with not including the string names

"PinRequest.ashx?requestId=" + this._requestId + "&isPinned=" + this._isPinned

Thanks for you help guys

LeviBotelho Thank you made me check something i was missing out when checking as its javascript

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top