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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:06:02+00:00 2026-05-27T15:06:02+00:00

I am using ASP .NET MVC 3 and I have an interesting problem to

  • 0

I am using ASP .NET MVC 3 and I have an interesting problem to solve that I am hoping for some advice on.

I have a page that has a number of divs inside it. The contents of each div changes over time and so currently I have a timer for each div running that makes a $.ajax request to the server which returns a PartialViewResult with the updated contents of the div. The partial view is quite complex and references other views.

The problem with this approach is that it does not scale very well. It could be that each user has a lot of these timers running and with a lot of users the server is constantly being hit. I would rather, therefore, make a single request to the server that returns, potentially, multiple div contents so it would be:

div1 { some html }
div2 { some html }

…

Then on the client I could put each bit of HTML into the correct position on the page.

I thought that what I could do is return JSON from the server but my problem is – how do I get the HTML? At the moment the razor compiler will run and turn my partial view cshtml files into HTML but if I am returning JSON, is it possible to programmatically call the razor compiler?

I found Razor Engine here: http://razorengine.codeplex.com/ that seems to do what I want but is it possible to do it with just vanilla ASP NET MVC?

Or, given the problem, is there a better way that I could achieve my goal?

Thanks for any help!

  • 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-27T15:06:03+00:00Added an answer on May 27, 2026 at 3:06 pm

    Create an Action that returns a new PartialView that renders all of those PartialViews.
    e.g.
    an action:

    public PartialViewResult AggregatedAction(args)
    {
        return PartialView();
    }
    

    with a view that contains:

    @Html.Action("IndividualAction1", null)
    @Html.Action("IndividualAction2", null)
    @Html.Action("IndividualAction3", null)
    

    See http://haacked.com/archive/2009/11/18/aspnetmvc2-render-action.aspx for more details.

    That way there is only one request and the rendering engine is being called from the right place, i.e. the view.

    Then with the result, you can search for the various divs and replace the html in the client.

    $('div#id1').html('div#id1',$(data));
    $('div#id2').html('div#id2',$(data));
    

    If the structure of your page allows it, you should use: http://api.jquery.com/load/ (as @Jorge says) to replace all of the html with one line.

    $('div#targetDiv').load('Controller\AggregatedAction', anyData);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ASP.NET MVC 2 and have a login page that is secured via
Using ASP.NET MVC & Spark, I have a view that is listing a number
I'm using ASP.NET MVC and have a model which has an image (byte array)
Using ASP.NET MVC 2.0, I have an actionlink that is used for comments on
I am using asp.net MVC to develop an application that will have ajax interactions.
I'm using ASP.NET MVC RC2. I have a set of classes that were auto-generated
using ASP.NET MVC 2 I have a navigation menu inside my Master Page. In
using ASP.NET MVC 1.0 and I have a action that returns a JsonResult and
I am using ASP.NET MVC C# I have a jQuery call that deletes a
Using ASP.Net MVC 1.0 I have a form with some input control on it.

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.