Viewbag null condition check giving error in the view
Hi Friends,
I am assigning value in the controller like this.
[HttpPost]
public Actionresult order(FormColletion formcollection)
{
Viewbag.startes = formcollection ["starters"];
return view();
}
Value of my viewbag is : gobi Manchuria,chicken 65
In my view What I am doing is
@if(Viewbag.startes !=null)
{
@foreach(var data in (string)viewbag.starters.split(','))
//assigning data values here
}
Now my question is if viewbag not contains values giving @symbol error if I remove null check condition giving object reference error.
What is the solution for this issue??
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Salman BegRank #284 · 8.8K reputationPosted Jan 13, 2020, 6:07 PM EST