public class AuthenticationController : Controller
{
[HttpGet("~/signin")]
public IActionResult SignIn() => View("SignIn", HttpContext.GetExternalProviders());
[HttpPost("~/signin")]
public IActionResult SignIn([FromForm] string provider)
{
// Note: the "provider" parameter corresponds to the external
// authentication provider choosen by the user agent.
if (string.IsNullOrWhiteSpace(provider))
{
return BadRequest();
}
if (!HttpContext.IsProviderSupported(provider))
{
return BadRequest();
}
// Instruct the middleware corresponding to the requested external identity
// provider to redirect the user agent to its own authorization endpoint.
// Note: the authenticationScheme parameter must match the value configured in Startup.cs
return Challenge(new AuthenticationProperties { RedirectUri = "/" }, provider);
}
[HttpGet("~/signout"), HttpPost("~/signout")]
public IActionResult SignOut()
{
// Instruct the cookies middleware to delete the local cookie created
// when the user agent is redirected from the external identity provider
// after a successful authentication flow (e.g Google or Facebook).
return SignOut(new AuthenticationProperties { RedirectUri = "/" },
SalesforceAuthenticationDefaults.AuthenticationScheme);
}
}
(!HttpContext.IsProviderSupported(provider)) & HttpContext.GetExternalProviders()
- 在Visual Studio 2017中生成错误,但它在Visual Studio代码
我不确定为什么这样做,但对这些问题的任何帮助都非常感谢。