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# - SharpDX Toolkit models rendering inside out -

c# - ajax - How to receive data both html and json from server? -