I think if you changed your AccountController.Login method from the default implementation.
[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
ViewBag.ReturnUrl = returnUrl;
return View();
}
To something like this:
[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
return new ChallengeResult("Twitter",
Url.Action("ExternalLoginCallback", "Account",
new { ReturnUrl = returnUrl }));
}
The ChallengeResult class is generated by the MVC template and looks like this for me.
private class ChallengeResult : HttpUnauthorizedResult
{
public ChallengeResult(string provider, string redirectUri) : this(provider, redirectUri, null)
{
}
public ChallengeResult(string provider, string redirectUri, string userId)
{
LoginProvider = provider;
RedirectUri = redirectUri;
UserId = userId;
}
public string LoginProvider { get; set; }
public string RedirectUri { get; set; }
public string UserId { get; set; }
public override void ExecuteResult(ControllerContext context)
{
var properties = new AuthenticationProperties() { RedirectUri = RedirectUri };
if (UserId != null)
{
properties.Dictionary[XsrfKey] = UserId;
}
context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider);
}
}
The effect of this though will be to automatically immediately redirect to Twitter when a user tries to log in and you will not be able to support any other login providers.
You will also probably need to make some changes to your account page to remove the ability to specify a local password for the user (Since it wouldn't make any sense to have that if you don't allow your users to use it).