TempData not cleared between requests when using ContainsKey


Recently I was trying to add a simple message to the top of the screen if the user had been logged out. This message, should appear only once. If the user navigates away from the page, it shouldn’t show again. So, it made sense to use TempData In my controller, I had something like this: _authenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); TempData["LoggedOut"] =...

Dynamic routes with ASP.net MVC – Category/Location mapping to controller


I’ve recently been looking in to building a directory type application with Asp.Net MVC One of the requirements would be to have SEO friendly URLs such as: —Surrey /restaurants being the “Category” /Camberley—Surrey being the “Location” So, I created a ‘CategoryController’ like this public class CategoryController : Controller { public ActionResult Index(string category, string location) { //do...

Session_Start event not firing


I’ve been scratching my head about this one for sometime… As I’m sure your aware (or you wouldn’t be reading this) in the Global.asax file, we have the following method: protected void Session_Start(object sender, EventArgs e) { } Placing a breakpoint on this method, I attached the debugger, ran up my application, and the breakpoint was not hit… What I would of...