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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:39:42+00:00 2026-06-13T00:39:42+00:00

If ASP.NET MVC2 code below shows message Test in Create controller response. In Mono

  • 0

If ASP.NET MVC2 code below shows message “Test” in Create controller response.

In Mono message does not appear apper in Create view.

Message appears in next response invoked after create.

How to dorce Mono to show TempData value in same request like in ASP.NET ?

[HttpPost]
public RedirectToRouteResult Create()
{
 TempData["Message"] = "Test";
 return RedirectToAction("Index");
}


public ActionResult Index() {
  return View();
  }

Site.Master:

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <script src="<%= Url.Content("~/Scripts/jquery/jquery-1.7.1.js")%>" type="text/javascript"></script>

 <% if (TempData["Message"]!=null) {
        %>
    $(function() {
        setTimeout( function() {
           showMessage ( '<%= TempData["Message"] as string %>');
           }, 300 );
      });
        <% } %>
    </script>
</head>
  • 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-13T00:39:43+00:00Added an answer on June 13, 2026 at 12:39 am

    I would recommend you consuming the TempData value inside the controller action and not inside the view:

    [HttpPost]
    public ActionResult Create()
    {
        TempData["Message"] = "Test";
        return RedirectToAction("Index");
    }
    
    public ActionResult Index() 
    {
        ViewData["Message"] = TempData["Message"];
        return View();
    }
    

    and inside the view:

    <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <script src="<%= Url.Content("~/Scripts/jquery/jquery-1.7.1.js")%>" type="text/javascript"></script>
    
        <% if (ViewData["Message"] != null) { %>
            $(function() {
                window.setTimeout(function() {
                    showMessage (<%= new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(ViewData["Message"]) %>);
                }, 300);
            });
        <% } %>
        </script>
    </head>
    

    By the way instead of using ViewData, I would recommend you using a view model and have your view strongly typed to this view model.

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

Sidebar

Related Questions

output cache is implemented in ASP.NET MVC2 using code below. GetVaryByCustomString method is not
I'm passing 2 hardcoded parameters to an ASP.Net MVC2 Controller Action with this code:
Does The StackExchange MiniProfiler http://code.google.com/p/mvc-mini-profiler/ work in ASP.NET MVC2? If so, how? When adding
i am using below code to show google map in asp.net MVC2: <script type=text/javascript
I'm trying to create an interface for a model class in ASP.NET MVC2 and
does anyone know any tool for 'code generation' using MVC2? I know that ASP
I try to port ASP .NET MVC2 password recovery code from Where to find
I am trying to convert the popular asp.net MVC 2.0 solr.net sample app code
I'm using ASP.NET MVC2 and I have the following object structure: public class IDealer
I have an ASP.NET MVC2 site connecting to a MySQL database via DbLinq. There

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.