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

  • Home
  • SEARCH
  • 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 6050789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:43:40+00:00 2026-05-23T07:43:40+00:00

If I have a custom object like this: public class StatisticsRequest { public string

  • 0

If I have a custom object like this:

public class StatisticsRequest
    {
        public string Level { get; set; }
        public string Analysis { get; set; }
        ...more properties
    }

Then can I declare an MVC2 controller like this?:

public ActionResult GetResponseStats(StatisticsRequest statsRequest)

and get my querystring parameters automatically parsed into my custom object?

It’s not working for me – can you do this?

Edit:

This is my entire controller class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Tradeshow.Models;

namespace Tradeshow.Controllers
{
    [Authorize]
    public class DashboardController : Controller
    {
        public ActionResult GetResponseStats(StatisticsRequest statsRequest)// string profileid, string analysis, string question, string answer, string omitheaders)
        {
            Tradeshow.Models.Mongo mongo = new Models.Mongo();
            // For top-level requests that don't specify the analysis, use the previously requested top-level analysis 
            if (statsRequest.IsTopLevelRequest)
            {
                if (statsRequest.Analysis == null || statsRequest.Analysis.Length == 0)
                {
                    statsRequest.Analysis = (String)Session["statsanalysistype"];
                }
                else
                {
                    Session["statsanalysistype"] = statsRequest.Analysis;
                }
            }
            string clientdatabasename = (String)Session["clientdatabasename"];
            Dashboard dashboard = mongo.BuildResponseDashboard(clientdatabasename,statsRequest);
            return PartialView("ProfileDashboard",dashboard);
        }
    }
}

This is my entire StatisticsRequest object:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Tradeshow.Models
{
    /// <summary>
    /// Encapsulates the properties that make up a statistics request for generating one or more graphs and charts
    /// </summary>
    public class StatisticsRequest
    {
        public string Level { get; set; }
        public string Analysis { get; set; }
        public string ProfileId { get; set; }
        public string Question { get; set; }
        public string Answer { get; set; }
        public string TimespanFormat { get; set; }
        public string TimespanValue { get; set; }

        public bool OmitHeaders
        {
            get
            {
                bool rc = false;

                if (String.Compare(Level, "profile", true) == 0) rc = true;

                return rc;
            }
        }

        public bool IsTopLevelRequest
        {
            get
            {
                bool rc = false;

                if (String.Compare(Level, "profile", true) == 0) rc = true;

                return rc;
            }
        }
    }
}

And the simplest test querystring (which fails) looks like this:

/Dashboard/GetResponseStats?profileid=123&unique=775765

A lot of the time only one or two of the parameters will be passed in the querystring.

Edit2

One other point – the StatisticsRequest object is just an arbitrary object, and has nothing to do with the View Model. I created the StatisticsRequest object purely to encapsulate the request, not to support any form-based views etc.

  • 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-23T07:43:40+00:00Added an answer on May 23, 2026 at 7:43 am

    If you call UpdateModel(statsRequest); the default model binder will fill in the data using query string and forms data if the properties match by name. You can also call TryUpdateModel(statsRequest); which will work only if all of the properties can be updated.

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

Sidebar

Related Questions

I have a custom list which inherits from Generic.List<T> like this: public class TransferFileList<T>
Lets say I have a custom data type that looks something like this: public
So I have two custom complex types like this (oversimplified for this example): public
I have a custom security principal object which I set in the global.asax for
I have a class MinMax which among other things contains this: public class MinMax
I have a custom object that implements INotifyPropertyChanged. I have a collection of these
I have a Repeater contol bound to a custom object (an EntitySpaces query) and
I've created a custom object, I have it appearing automatically on the Account details
I have a DateTime object that I need to print in a custom gridlike
I have a single NSDictionary object which contains a large number of custom objects.

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.