You have code directly in the class, you need a method. For example:
public class QuestionnaireController : Controller
{
public ActionResult Index()
{
ViewBag.EmptyGuid = Guid.Empty;
return View();
{
}
This error really has nothing to do with MVC: that is invalid C# syntax and you're getting a compilation error.
On a side note - I'd recommend not using ViewBag
at all (or almost ever) when you can use a strongly typed model. Same goes for rowobject[6]
: I'm not sure what that is, but you definitely don't want data readers on your View. By the time the data is in the view, it should have already been converted to a model.
On the other hand, I don't think it is wrong to use Guid.Empty
or default(Guid)
on a view.