Reputation: 159
ASP.Net MVC 2 Beta -
I am aware there are some changes to TempData in MVC 2 Beta.
When trying to use TempData if the key name get/set have different case sensitivity, then the key doesn't seem to get destroyed.
e.g.
in Controller
TempData["Message"] = message;
in View
<% = TempData["message"]%>
My view will is play the value in message, but it never gets destroyed. So if I redirect elsewhere it sticks around. I don't believe case sensitivity was an issue in MVC 1?
Upvotes: 0
Views: 360
Reputation: 32828
This appears to be a bug. I've filed a work item in our tracking database. Thanks for the report.
Upvotes: 2
Reputation: 15900
Interesting. I guess because it doesn't care about case when you set the tempdata value, you could view it as a bug.
E.g. if you do:
TempData["Message"] = "Capital";
TempData["message"] = "Lower case";
Then access TempData["Message"]
- it will equal Lower case
.
So yeah, you could view it as a bug.
To avoid anything like that, I like to have a set of constants that I use to get and set ViewData and TempData values.
E.g.
public static class ViewDataKeys
{
public const string HeadTitle = "HeadTitle";
public const string PageTitle = "PageTitle";
public const string FirstLevelMenuKey = "FirstLevelMenu";
public const string SecondLevelMenuKey = "SecondLevelMenu";
... etc ...
}
HTHs,
Charles
Upvotes: 0