asp.net mvc - Is checking ViewBag.Val != null correct in Razor? -


what's proper way check in razor if viewbag has value set? know i can do

if(viewbag.foo != null) {   ... } 

but looking in events stream in vs 2015 notice generates (handled) runtimebinderexception.

the fact throws error leads me suspect not correct way check presence of value, , harming performance (though have not done testing). in addition doesn't distinguish between value being absent , value being set null.

is there more correct approach?

there no way defined razor developers, can see this using extension method.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

Delphi 7 and decode UTF-8 base64 -