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 8840937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:35:09+00:00 2026-06-14T10:35:09+00:00

How do pass a JavaScript object into ASP.NET Handler and parse the values? I

  • 0

How do pass a JavaScript object into ASP.NET Handler and parse the values?

I have created an Complex type object like:

function AccountObjCreate() {
var AccountsView = {};
AccountsView.Username = null;
AccountsView.Email = null;
AccountsView.Password = null;

return AccountsView;
}

And fill that object like:

var aView = AccountObjCreate();
aView.Username = $('#tbUserName').val().trim();
aView.Email = $('#tbEmail').val().trim().toLowerCase();
aView.Password = $('#tbPassword').val().trim();

Then I am calling:

$.post("/Handlers/AccountHandler.ashx", { obj: aView },
        function (results) {
            if (results.isSuccess) {
                alert(results.msg);
            } else {
                alert(results.msg);
            }
        }, "json");

When I view it in the console I see all my data within aView as json.

My ASP.NET Handler page is

context.Response.ContentType = "application/json";
context.Response.ContentEncoding = Encoding.UTF8;
string obj = context.Request["obj"];

But the obj is NULL.

  • 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-06-14T10:35:10+00:00Added an answer on June 14, 2026 at 10:35 am

    In order to get the object through to the server you should serialize it into a string (you could use the method described here or include the JSON library for javascript here) and then deserialize it using the .NET JavaScriptSerializer class.

    JS code.

    var data = {
        obj: JSON.stringify(aView)
    };
    $.post("/Handlers/AccountHandler.ashx", data, function(results) {
        if (results.isSuccess) {
            alert(results.msg);
        } else {
            alert(results.msg);
        }
    }, "json");​
    

    Then on the server handler you can parse the JSON string with the mentioned JavaScriptSerializer class.

    public class AccountsView {
        public string Username;
        public string Email;
        public string Password;
    }
    
    public void ProcessRequest(HttpContext context)
    {
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        string value = context.Request["obj"];
        var aView = serializer.Deserialize(value, typeof(AccountsView));
    
        context.Response.ContentType = "application/json";
        context.Response.ContentEncoding = Encoding.UTF8;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to pass a nested JavaScript object to my ASP.NET MVC Action
In javascript, I have an object that I am trying to pass but not
I have a Javascript object that I want to pass in more parameters, but
I have code <a href=javascript:someFunction(this); tabindex=0>Some text</a> Is it possible to pass element into
I want to pass a date object into a function and determine what the
I have a couple of standard ASP.NET web methods that I'm calling from javascript
I have a jQuery library that wants you to pass it a JavaScript object
I have this Javascript data: [{id:123,type:test},{id:154,type:another}] How would you transform that into something so
I want to pass JavaScript objects (JSON and function objects) into my ActiveX control.
I created a function to take location input, pass it to Google Maps Javascript

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.