此控制器的构造函数返回错误“} 预期”。Visual Studio 没有将其识别为构造函数。其他错误包括“方法必须有返回类型”。
这段代码有什么问题?
namespace blahblah.Controllers
{
public class HomeController : Controller
{
private IUserRepository userRepository;
public HomeController()
{ //} expected here
public Model1Container db = new Model1Container();
this.userRepository = new UserRepository(db);
}
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}
public ActionResult About()
{
return View();
}
}
}