這是由框架生成的默認AccountController.cs。爲什麼MVC提供的Default AccountController中有2個構造函數?
public class AccountController : Controller
{
public IFormsAuthentication FormsAuth { get; private set; }
public IMembershipService MembershipService { get; private set; }
public AccountController()
: this(null, null)
{
}
public AccountController(IFormsAuthentication formsAuth, IMembershipService membershipService)
{
FormsAuth = formsAuth ?? new FormsAuthenticationService();
MembershipService = membershipService ?? new AccountMembershipService();
//---
}
這很容易理解。
public AccountController(IFormsAuthentication formsAuth,
IMembershipService membershipService)
{
FormsAuth = formsAuth ?? new FormsAuthenticationService();
MembershipService = membershipService ?? new AccountMembershipService();
}
這是什麼?它的目的是什麼?對於賬戶管理員來說是特別的還是對其他控制器的要求?並且,爲什麼我應該將其納入我的項目?
public AccountController()
: this(null, null)
{
}
他們似乎在另外兩個地方使用這種類型的構造函數。
感謝您的幫助