尝试登录时收到以下异常:
The current request for action 'Login' on controller type 'AccountController' is ambiguous between the following action methods:
System.Web.Mvc.ActionResult Login() on type Sandbox.Web.Controllers.AccountController
System.Web.Mvc.ActionResult Login(Sandbox.Web.Models.Account.LoginModel) on type Sandbox.Web.Controllers.AccountController
好吧,我知道这意味着什么,但我不明白为什么我(仅)在登录时收到它。我的登录代码已像我所有其他操作一样构建
public class AccountController : Controller
{
// ctor...
[AllowAnonymous]
public ActionResult Login()
{
// ...
}
[AllowAnonymous]
[HttpPost]
public ActionResult Login(LoginModel model)
{
// ...
}
}
我的其他动作是这样构建的
ActionResult Create()
[HttpPost]
ActionResult Create(OrderModel model)
ActionResult Edit(int id)
[HttpPost]
ActionResult Edit(OrderModel model)
他们工作没有问题。
我在 MVC 5.2.7 应用程序中使用 Autofac 4.9 和 Autofac.Integration.Mvc (4.0)。我从默认 MVC 模板更改的唯一部分是依赖解析器
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
如果我在一切正常[HttpGet]之前放置一个。Login()
任何人都知道如何使它工作或为什么它不起作用?