I'm trying out MVC Scaffolding in a VB.NET MVC3 project and running into an issue with late binding with Option Strict set on (and I want it on).
This works in C#:
public ActionResult Create()
{
ViewBag.PossibleTeams = context.Teams;
return View();
}
but the virtually the same code in VB.NET:
Public Function Create() As ActionResult
ViewBag.PossibleTeams = context.Teams
Return View()
End Function
causes the compiler error Option Strict On disallows late binding. I took a look at the documentation here: http://msdn.microsoft.com/en-us/library/system.web.mvc.controllerbase.viewbag(VS.98).aspx but it wasn't very helpful.
I notice that a new empty application in C# uses the ViewBag
in the HomeController
but the VB.NET version uses ViewData
, so maybe this is a VB.NET limitation.