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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:06:04+00:00 2026-05-24T21:06:04+00:00

I have an PartialViewResult action which renders a PartialView that I call from a

  • 0

I have an PartialViewResult action which renders a PartialView that I call from a $.ajax call on the page.

That PartialView also has a foreach loop for the items in the VM and within that PartialView I have two RenderAction that render two other Partials.

It all works fine, except for the speed at which it’s rendered. When I comment out the two nested RenderAction, the main partial view renders extremely fast. When I uncomment them, the main partial view renders between 3 to 5 seconds. Even if I remove all data from the partial views and all data from the actions to only return an empty view, it still takes 3-5 seconds.

Somehow, my app is having problems rendering these two partials even when they’re empty.

My code:
Main action:

public PartialViewResult MyTasks(int milestoneId, int currentPage = 1)
{
    var mergedTasks = new List<MergedTask>();   
    var TrackingTeams = _TrackingTeams.GetAll().ToList();
    var pagingInfo = new PagingInfo() {CurrentPage = currentPage, ItemsPerPage = 10, TotalItems = _TrackingTeams.GetAll().Count() };                                                                     
    mergedTasks.AddRange(from TrackingTeam in TrackingTeams
                       let task = allTasks.Single(x=>x.TestId == (int)TrackingTeam.TrackingTask.TestId)
                       select new MergedTask()
                       {                           
                           Summary = TrackingTeam.TrackingTask.Description,
                           InternalId = task.Id,
                           DevTrackingTask = TrackingTeam.TrackingTask,
                           LastUpdate = task.DateModified
                       });

    return PartialView(new DevTrackingTaskViewModel
    {
        MergedTasks = mergedTasks,
        Category = _categories.GetById(categoryId),
        PagingInfo = pagingInfo
    });
}

The ViewModel associated with it:

public class TrackingTaskViewModel
{
    public List<MergedTask> MergedTasks { get; set; }
    public int CountTasks { get; set; }
    public PagingInfo PagingInfo { get; set; }
    public Category Category { get; set; }
}

public class MergedTask
{
    public int InternalId { get; set; }
    public string Summary { get; set; }
    public TrackingTask TrackingTask { get; set; }
    public DateTime LastUpdate { get; set; }
}

My main PartialView:

@foreach (var item in Model.MergedTasks)
{
    <script type="text/javascript">
        $(document).ready(function () {
            $("#TrackingTask@(item.TrackingTask.Id)").hover(function () {
                if ($("#snapshotFixerForTrackTask@(item.TrackingTask.Id)").length == 1) {
                    $("#expandTrackingTaskForTask@(item.TrackingTask.Id)").removeClass("hide");
                }
                else {
                    $("#expandTrackingTaskForTask@(item.TrackingTask.Id)").toggleClass("hide");
                }
            });
        });
    </script>

    <div class="TrackingTaskDiv" id="TrackingTask@(item.TrackingTask.Id)">
        <div class="TrackingContainer">
            <div id="flagsForTrackingTask@(item.TrackingTask.Id)" class="flags">
               @{Html.RenderAction("ShowFlags", "Task", new { trackingid = item.TrackingTask.Id });}
            </div>

            <div id="TestStatusForTrackTask@(item.TrackingTask.Id)" class="TestStatusWrapper">
                @{Html.RenderAction("CheckTrackStatus", "Task", new { trackingid = item.TrackingTask.Id });} 
            </div>
        </div>
        <div id="expandTrackingTaskForTask@(item.TrackingTask.Id)" class="expandTrackingTask collapsed hide"></div>
    </div>    
}

I can paste in the Action for the “ShowFlags” and “CheckTrackStatus” if needed. But as I mentionned even if I remove all the code from the action and the view the rendering still takes 3-5 seconds to render the whole view, there’s no difference.

One solution we came up with would be to remove the partials altogether, put the VM of each partial inside the main VM and do the same for the HTML in the partials. But I like the idea of compartmentalizing specific features on a view.

  • 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-24T21:06:04+00:00Added an answer on May 24, 2026 at 9:06 pm

    LanFeusT (great name!!),

    RenderAction will cause a performance overhead as it makes a complete MVC cycle, rather than just using the current controller context. you may be advised to seek an alternative approach (such as including the required elements in your viewModel). i found this out the hard way as well and it was only when profiling my code that i appreciated the amount of reflection going on for each new RenderAction call (which in 99% of circumstances is both convenient and appropriate).

    So my bottom line advice – look at extending your viewmodel.

    I urge you to google RenderAction vs RenderPartial for further info..

    see:

    RenderAction RenderPartial

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

Sidebar

Related Questions

Trying to have a AJAX action link which when clicked, should do a HttpGet
I have a controller action UpdateCustomer(CustomerDto customer) that returns a PartialViewResult with a model
I have an @Ajax.ActionLink that replaces his own wrapper, with another content that also
I have a view in which I am attempting to do an ajax call
I have an ASP.NET MVC action method which uses model binding to accept a
Cannot call action method 'System.Web.Mvc.PartialViewResult FooT' on controller 'Controller' because the action method is
I have some AJAX calls that render PartialViewResults via the jQuery.AJAX method. This works
So I have an MVC action with the header: public PartialViewResult PersistPlaceholderItems(ModelObject model, int
With ASP.NET MVC3 (Razor) I have a simple page that loads a jQuery UI
I have an Action as follows: public PartialViewResult MyActionIWantToTest(string someParameter) { // ... 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.