title: MVC-4 Change ViewBag.Message on server side?
body: <p>I am beginner in MVC coding.<br>
   When the application starts,  the ViewBag.Message is: Choose a file to upload.</p>
  
  <p>After a successful upload, it changes to: File uploaded successfully!</p>
  
  <p>Is there a way I can make it to return and show the "Choose a file to upload" message again after around 5 seconds, without using any javascript ?
   I thought if mvc had some built in time function I could use maybe ?</p>
  
  <p><a href="https://github.com/xoxotw/mvc_fileUploader" rel="nofollow">https://github.com/xoxotw/mvc_fileUploader</a></p>
  
  <p>My view:</p>
  
  <pre><code>@{
      ViewBag.Title = "FileUpload";
  }
  
  &lt;h2&gt;FileUpload&lt;/h2&gt;
  
  &lt;h3&gt;Upload a File:&lt;/h3&gt;
  
  
      @using (Html.BeginForm("FileUpload", "Home", FormMethod.Post, new {enctype = "multipart/form-data"}))
      { 
          @Html.ValidationSummary();
          &lt;input type="file" name="fileToUpload" /&gt;&lt;br /&gt;
          &lt;input type="submit" name="Submit" value="upload" /&gt;  
          @ViewBag.Message
      }
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  
  namespace Mvc_fileUploader.Controllers
  {
      public class HomeController : Controller
      {
          public ActionResult Index()
          {
              ViewBag.Message = "Choose a file to upload!";
              return View("FileUpload");
          }
  
          [HttpPost]
          public ActionResult FileUpload(HttpPostedFileBase fileToUpload)
          {
  
              if (ModelState.IsValid)
              {
                  if (fileToUpload != null &amp;&amp; fileToUpload.ContentLength &gt; (1024 * 1024 * 1))  // 1MB limit
                  {
                      ModelState.AddModelError("fileToUpload", "Your file is to large. Maximum size allowed is 1MB !");
                  }
  
                  else
                  {
                      string fileName = Path.GetFileName(fileToUpload.FileName);
                      string directory = Server.MapPath("~/fileUploads/");
  
                      if (!Directory.Exists(directory))
                      {
                          Directory.CreateDirectory(directory);
                      }
  
                      string path = Path.Combine(directory, fileName);
                      fileToUpload.SaveAs(path);
  
                      ModelState.Clear();
                      ViewBag.Message = "File uploaded successfully!";
                  }
              }
  
                  return View("FileUpload");
  
          }
  
  
  
          public ActionResult About()
          {
              ViewBag.Message = "Your app description page.";
  
              return View();
          }
  
          public ActionResult Contact()
          {
              ViewBag.Message = "Your contact page.";
  
              return View();
          }
      }
  }
  </code></pre>