Is there a way to clear ViewBag
?
VubUag
has no setter, so it can not be easily terminated:
ViewBag = null;
I also think that it can not be repeated on it and erase its dynamic properties, because you can not create an example of dynamic
.
Note: I know that ViewBag
is a bit of a smell odor, because it has not been typed strongly, and basically one of the global variables There is a huge collection and we are taking it away, but still need to deal with it in the meantime.
You can just call
ViewData .clear ();
See Bag as it uses internally.
Here the example is working - If you reject the comments made, the text displayed will be cleared
Here is a ViewBag for MVC:
Public Dynamic ViewBag {get {if (_dynamicViewDataDictionary == null} {_dynamicViewDataDictionary = new dynamic widget (=)); data};} return _dynamicViewDataDictionary;}}
And a part of that
// Implementing this function improves the debugging experience because it has all // properties The debugger provides a list with the currently defined object, IEnumerable & lt; string & gt; GetDynamicMemberNames (see ViewData.Keys;} Public Override Bull TryGetMember (GetMemberBinder Binder, Out Object Result) {Results = ViewData [binder.Name]; // Because ViewDataDictionary always returns a result, even if the key is not present, always return true;} Public override balls TrySetMember (SetMailBinder Binder, Object Value) {ViewData [binder.Name ] = Value; // Return the return true return so you can always set a key in the dictionary; }
So you can see that it depends on the ViewData object
No comments:
Post a Comment