Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6685883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:06:31+00:00 2026-05-26T05:06:31+00:00

I’m having problems passing an array parameter to my .ashx handler. Querystring parameters work

  • 0

I’m having problems passing an array parameter to my .ashx handler. Querystring parameters work fine, but I don’t know how to access the array from within the ashx file.

My array is a list of strings called list. This is how I call the getJSON method:

jQuery.getJSON('Handlers/AccessoryUpdateHandler.ashx?action=updateselection&a=' + a_sku, function (list) {
            //...
        });

In AccessoryUpdateHandler.ashx I can get the querystring parameter using context.Request.QueryString["a"];

But how do I get the array data? I’ve looked at the Request.QueryString object but there’s nothing there that looks like my array.

If there’s a better way of doing this I’d also be interested to know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:06:32+00:00Added an answer on May 26, 2026 at 5:06 am

    Perhaps you shouldn’t rely on QueryString to pass the kind of data. I would advice you to use “POST” method instead. In either case, using the approach you are using, you wont be able to pass the data as an array. Convert the array into a string. A utility like stringify() can come in handy here if you dont want to convert the array into a string manually. When you extract the string from the Request.QueryString or Request.Form (in case you use post) in the handler, you can easily use JavaScriptSerializer to deserialize using a simple C# class that has a schema similar to your json array.

    Edited: Illustration

    An array like:

    var ary = [{ "id": "1", "name": "Mark" }, { "id": "2", "name": "John"}];
    

    can be converted to a string like:

    var aryS = "[{\"id\":\"1\",\"name\":\"Mark\"},{\"id\":\"1\",\"name\":\"Mark\"}]";
    

    then, your QueryString can be constructed as:

    jQuery.getJSON('Handlers/AccessoryUpdateHandler.ashx?action=updateselection&a=' + aryS, function (list) {
            //...
        });
    

    when you go to your handler code, you can have a simple class to help you deserialize the data:

    class Rec 
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
    

    with that in place, the last step to deserialize is:

    string s = context.Request.QueryString["a"]; // HttpContext context
    var jserializer = new JavaScriptSerializer();
    var ary = jserializer.Deserialize<Rec[]>(s);
    

    Note you have to use Rec[] in the Deserialize function since you are deserializing into an array. ary will be an array of Rec with all your data from your javascript array. You need to reference System.Web.Extensions to use JavaScriptSerializer

    EDIT:

    I thought you were talking about an array of objects. If its just an array of *long*s, the following lines should be sufficient:

    string s = context.Request.QueryString["a"]; // HttpContext context
    var jserializer = new JavaScriptSerializer();
    var ary = jserializer.Deserialize<long[]>(s);
    

    and you dont need to create a class. you would only need that if you had a array of json objects

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.