tags:

views:

50

answers:

1
public ActionResult Index()
    {

        var tickets =
            DependencyContainer.DomainController.ShowTickets();
        if(tickets==null)
        {
            ViewData.Add("Error","Associate not found");
            return RedirectToAction("Index", "Home");//Doesn't fire the index?
        }
        return View();

Home controller method is as follows and only fires on the debugger startup, and after the redirect IF I hit F5.

    public ActionResult Index()
    {
        ViewData["Message"] = "Welcome to Home Loans and Insuring Technology Ticketing";
        //if (TempData.ContainsKey(ErrorKey))
        //{
        //    ViewData[ErrorKey] = TempData[ErrorKey];
        //    TempData.Remove(ErrorKey);
        //}
        return View();
    }

Redirect doesn't fire the controller?

A: 
  1. You must use TempData when redirecting. ViewData will not work when set before a redirect.
  2. Do you cache the site index? Does the browser cache it? Look at the request and response with Firebug or Fiddler.
Craig Stuntz
if caching is the problem, how can I force a reload?
Maslow
Depends who is caching it. The generic answer is "with request or response headers."
Craig Stuntz
I'm in firebug but I don't see where to sort out who might be caching something. How would I change this `return RedirectToAction("Index", "Home");` to have it specify load a fresh copy for each?
Maslow
1) If you see a request, and a response from the server, then the browser isn't caching. If no request/response, then it is. 2) If a breakpoint in the action does not stop, then the web server is caching. If it does, then it isn't. 3) You can't "specify a fresh copy" in a redirect (except, perhaps, with a bogus query string param). You have to specify cache policy correctly to begin with.
Craig Stuntz