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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:20:55+00:00 2026-05-22T20:20:55+00:00

Hi I have this as one of my controllers: [HttpPost] public JsonResult GetPinPoints(string Id)

  • 0

Hi I have this as one of my controllers:

[HttpPost]
        public JsonResult GetPinPoints(string Id)
    {
        Frames rslt = null;

        string connString = ConfigurationManager.ConnectionStrings["MongoConnStringNew"].ToString();
        MongoUrl murl = new MongoUrl(connString);
        MongoServer mgconf = new MongoServer(murl);
        try
        {
            mgconf.Connect();
            MongoDatabase frmlydb = mgconf.GetDatabase("framely");
            MongoCollection<Frames> collection = frmlydb.GetCollection<Frames>("Frames");
            ObjectId oid = new ObjectId(Id);
            Frames frms = collection.FindOne(Query.EQ("_id", oid));

            if (frms != null)
            {
                rslt = frms;
            }
        }
        catch (Exception ex)
        {
        }
        finally
        {
            mgconf.Disconnect();
        }

        return Json(rslt.CoordinatesObj.ToJson());
    }

The mongo object looks like this:

{"MetaTagsObj":{"Meta1":"my fam","Meta2":"lololo","Meta3":"lulz"},"PictureID":"http://framely.s3.amazonaws.com/0b7a9a72-c61b-4dec-a814-40b003072e31.jpg","UserID":"1","CoordinatesObj":[{"Position":1,"Top":182,"Left":20,"Height":73,"Width":90},{"Position":2,"Top":69,"Left":103,"Height":98,"Width":1...

I use an ajax jquery function to call the controller that looks like this:

$("#mybutton").click(function(){
           $.ajax({
                url: '/Member/GetPinPoints',
                type: "POST",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                success: function(data) {
            alert(data);
            },
            error: function() {

            alert("error");
            }
            });


    return false;
});

I dont think I am doing this right, I think it has to do with the way I return the json object. I keep getting this error:

{“Object reference not set to an instance of an object.”}

right where I am returning the Json object.

  • 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-22T20:20:56+00:00Added an answer on May 22, 2026 at 8:20 pm

    The return Json(myObject) statement should take an object that’ll be serialised to JSON then returned to the browser as a string, but by calling ToJson() the rslt.CoordinatesObj object will be serialised twice.

    It’s also possible CoordinatesObj isn’t being deserislised properly, so it’s throwing an exception because ToJson() is called on a null object.
    The Frames class should look something like this to handle deserialising the CoordinatesObj array:

    public class Frames
    {
        IEnumerable<Coordinate> CoordinatesObj { get; set; }
    
        public class Coordinate
        {
            int Position { get; set; }
            int Top { get; set; }
            int Left { get; set; }
            int Height { get; set; }
            int Width { get; set; }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two test method calling to controller: This one passed: [Test] public void
Is there any way to have this: [one[two]][three] And extract this with a regex?
I'm training code problems like UvA and I have this one in which I
I have this in one of my haml views: -form_for :news_item_comment, :url=>{:id => comment.id,
Let's say I have this in one of my targets: <path id=files> <fileset dir=${env.DIRECTORY}
I have this field in one form : <input type=text name=promocode id=promoCode value= style=width:24%
I have texts like this one: this is a text in [lang lang=en ]english[/lang]
Let's suppose I have xml like this one: <Server Active=No> <Url>http://some.url</Url> </Server> C# class
I have this code that has one button that let's me choose an entry
I have a Table like this one: |UserId | ContactID | ContactName --------------------------------------- |

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.