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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:11:32+00:00 2026-05-27T11:11:32+00:00

I am trying to implement a remote REST service which is used to handle

  • 0

I am trying to implement a remote REST service which is used to handle all logic for my MVC3 web application, and so far I am able to retrieve the serialized object from the webservice, but I am stuck on deserializing the object into my ViewModel to pass to the View.

Here is my controller:

[HttpGet]
public ActionResult Index()
{
    string versions;
    using (var webClient = new WebClient())
    {
        versions = webClient.DownloadString("http://myservice/GetVersions");
    }

    // deserialize JSON/XML somehow...
    //IEnumerable<VersionViewModel> model = ?

    return View(model);
}

What do I need to do to convert the JSON I recieve from the webservice to a ViewModel to render my view? Thanks.

  • 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-27T11:11:32+00:00Added an answer on May 27, 2026 at 11:11 am

    You could use RestSharp for the initial request, which should be able to automatically convert the JSON to a suitable data transfer object (DTO). From there, you could use something like AutoMapper to convert from DTO -> ViewModel class.

    The DTO (without knowing what your JSON looks like, of course):

    public class VersionDto
    {
         public string Name { get; set; }
         public string Version { get; set; }
    }
    

    The final result something like:

    [HttpGet]
    public ActionResult Index()
    {
        var client = new RestClient ("http://myservice");
        List<VersionDto> versions = client.Execute<List<VersionDto>> (new RestRequest ("/GetVersions"));
    
        var vms = Mapper.Map<IEnumerable<VersionDto>, IEnumerable<VersionViewModel>> (versions);
    
        return View(vms);
    }
    

    The RestSharp wiki has lots of docs on how it maps the JSON onto your DTO classes, letting you worry less about serialization, and more about your business logic.

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

Sidebar

Related Questions

I'm trying to implement a generic way of adding remote validation to xVal /
All I am currently trying implement something along the lines of dim l_stuff as
trying to implement a dialog-box style behaviour using a separate div section with all
im trying to implement a custom error page, what i want to be able
I am trying to implement security for the following architecture: Web tier: Tomcat 7
I am trying to implement a remote object implementation using xmlrpc, and python 3.
I am trying to implement a HTTP based chat here. All the chat messages
I have been trying to implement remote debugging in two different scenarios both without
I am trying to implement my own remote desktop solution in java. Using sockets
I am implementing web services for a PHP application and am trying to understand

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.