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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:51:45+00:00 2026-06-18T17:51:45+00:00

I have the following Controller Action: public ActionResult MyAction(…) { ActionResult result = View(MyView,

  • 0

I have the following Controller Action:

public ActionResult MyAction(...)
{
    ActionResult result = View("MyView", new MyModel());

    var fruit = TempData["Fruit"];
    // Do something with the fruit

    return result;
}

and this MyView.cshtml

@model MyModel
@{ 
    TempData["Fruit"] = "Mango";
}

When I put a breakpoint in the View where TempData["Fruit"] is set, it isn’t called before the “return result” in the Action. The Razor rendering seems to be delayed.

How can I force the View to be rendered on return from the result = View(..) call?

Note: Don’t worry about this simplistic example. We have a real use case where a solution to this would really be needed but I didn’t want to burden the question any further.

  • 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-06-18T17:51:46+00:00Added an answer on June 18, 2026 at 5:51 pm

    The View isn’t rendered until after the Action is complete. You can call result.ExecuteResult(ControllerContext) to force the early execution of the ActionResult inside the action like this:

        ActionResult result = View("Details", new PageModel(page));
        result.ExecuteResult(ControllerContext);
    

    But you will then have a problem because the ActionResult will be executed again when the action returns the result, so you will have to cancel that second execution.

    You can do this like so:

        protected override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            if (cancelTheResult)
            {
                filterContext.Cancel = true;
            }
            base.OnResultExecuting(filterContext);
        }
    

    This all does seem like a bit of a hack, but in some scenarios it seems necessary. For instance if a child action needs to tell the top level action to carry out a redirect, we won’t know the redirect is required until the child action completes, but the child action won’t be completed until too late. This is the only workaround I’ve been able to find.

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

Sidebar

Related Questions

I have the following controller action: public ActionResult Edit(int id) { var news =
I have the following controller action public ActionResult EditFocus(int id) { var Focus =
I have the following controller Action: public ActionResult Details(int id) { Seguimiento seguimiento =
i'm new to routing in aspnet mvc.. i have following code: Action Controller public
Suppose you have the following controller action [HttpPost] public ActionResult Save( CustomerModel model )
Inside my controller's action I have the following code: public ActionResult GridAction(string id) {
On ASP.NET MVC 3, assume that we have following controller action: public ActionResult Index()
I have the following action/controller on MVC3: [HttpPost] public ActionResult AX_AddItemResponse(ItemResponsesVM response) { return
I have the following controller action: public ActionResult Details(string pk) { IEnumerable<ContentDetail> model =
I have the following controller action: [HttpGet] public JsonpResult getTestValues(int? entityId, int? id) {

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.