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 -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -