asp.net mvc - MVC return View(model) Cannot perform runtime binding on a null reference -


this unclear me.
code looks this

 public actionresult viewdevice(string id)  {     fooobject model = new fooobject();      if (id == null)        return view(model);      model = somemethodthatreturnsfooobject(id);      return view(model);  } 

on view, check if model null, i'm assuming work.

when id not null, model variable filled fooobject.fill , displays on view.

when id null ...the controller gets error @ runtime:
"cannot perform runtime binding on null reference".

any reason why???

you don't need return empty model object this:

public actionresult viewdevice(string id)  {      if (id == null)        return view();       fooobject model = somemethodthatreturnsfooobject(id);      return view(model);  } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -