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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:54:07+00:00 2026-05-31T20:54:07+00:00

I have this (simplified) class: public class StarBuildParams { public int BaseNo { get;

  • 0

I have this (simplified) class:

public class StarBuildParams
{
    public int BaseNo { get; set; }
    public int Width { get; set; }
}

And I have to transform instances of it to a querystring like this:

"BaseNo=5&Width=100"

Additionally I have to transform such a querystring back in an object of that class.

I know that this is pretty much what a modelbinder does, but I don’t have the controller context in my situation (some deep buried class running in a thread).

So, is there a simple way to convert a object in a query string and back without having a controller context?

It would be great to use the modelbinding but I don’t know how.

  • 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-31T20:54:08+00:00Added an answer on May 31, 2026 at 8:54 pm

    You can use reflection, something like this:

    public T GetFromQueryString<T>() where T : new(){
        var obj = new T();
        var properties = typeof(T).GetProperties();
        foreach(var property in properties){
            var valueAsString = HttpContext.Current.Request.QueryString[property.PropertyName];
            var value = Parse( valueAsString, property.PropertyType);
    
            if(value == null)
                continue;
    
            property.SetValue(obj, value, null);
        }
        return obj;
     }
    

    You’ll need to implement the Parse method, just using int.Parse, decimal.Parse, DateTime.Parse, etc.

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

Sidebar

Related Questions

I want to have immutable Java objects like this (strongly simplified): class Immutable {
Suppose I have class like this (simplified): class Foo_p; class Foo { private: Foo_p
I have something like that (simplified) class A { public: virtual void Function ()
in a simplified version, what i have is this: public class MyLabel extends JLabel
I have a class (simplified example) like : public class SomeCollection : ICloneable {
Consider this simplified example: #include <list> typedef std::list<int> IntList; class KindaIntList { public: IntList::const_iterator
This is a simplified version of the original problem. I have a class called
I have code like this (simplified): def outer(): ctr = 0 def inner(): ctr
I have a table like this (simplified): ID | Name | Parent --------------------------------- 1
I have this code (which is way simplified from the real code): public interface

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.