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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:37:51+00:00 2026-05-18T01:37:51+00:00

I have an app that only ever loads a full view one time. My

  • 0

I have an app that only ever loads a full view one time. My reason for doing this is not important. What is important is that the rest of the content is only ever going to come back in partial views. In addition to some content I have some JSON objects I’d like to pass back and forth to and from the server with each AJAX request.

Is there a way to return a JSON object with a view as one of its properties? This would be extremely useful and would save on bandwidth as my current workaround is to make two ajax calls, one for the JSON and one for the partial view which not only takes more time and more bandwidth, but it also requires two separate action methods and some fancy tricks on the server side. Serializing a view into a JSON object would solve all my problems.

What is the best way to accomplish this and what downsides (if any) would there be to doing this?

  • 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-18T01:37:51+00:00Added an answer on May 18, 2026 at 1:37 am

    Here’s an interesting tidbit of code that seems to do what I want and preserves model binding from what I can tell.

    protected string RenderPartialViewToString(string viewName, object model)
    {
         controller.ViewData.Model = model;
    
         using (StringWriter sw = new StringWriter())
         {
              ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, viewName);
              ViewContext viewContext = new ViewContext(controller.ControllerContext, viewResult.View, controller.ViewData, controller.TempData, sw);
              viewResult.View.Render(viewContext, sw);
    
              return sw.GetStringBuilder().ToString();
         }
    }
    

    Works like a charm. I just use this and pass the string as a JSON parameter and then on the client I read the parameter and drop it in it’s appropriate container. I’m very excited to have this working.

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

Sidebar

Related Questions

I have built an app that works only when not run as a Windows
I have an app that only crashes for one of my tester’s - no
Hi I have an app that supports iOS 3 however I've only ever tested
I have a web app that only registered users can use, therefore I should
i have an app that sends out email but i have to only send
I have some external Javascript files in my GWT app that I only want
I have a new iPhone app that has the following (and only the following)
I have code that is triggered on launch only after the app is upgraded
this is my first ever question. I am developing a iPad app that allows
I have a WPF app that from time to time needs to perform a

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.