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 this code in one of my controllers to get access to eventful.
In one of my controllers, I do have a return that looks like this:
In an ASP.NET MVC3 project, I have 2 controllers: one is HomeController.cs public class
I have two test method calling to controller: This one passed: [Test] public void
I have the following controller [HttpPost] public JsonResult Update(List<DeliveryNoteDisplay> DeliveryNotes, UserSession userSession) { //
I have a create method in one controller and at the end of this
I have this one class: say InterClass . This class is declared in say,
I have this WinForms project (based on this one , but modified for SharePoint
This one is a little tricky. Say I have this XmlDocument <Object> <Property1>1</Property1> <Property2>2</Property2>
I have this fiddle : http://jsfiddle.net/XjeCf/1/ that works like I want and this one

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.