이 클래스는 Microsoft 샘플에서 약간 수정되었습니다.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using Root.Web.TokenStorage;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OpenIdConnect;
using System.Security.Claims;
using System.Web;
using System.Web.Mvc;
namespace Root.Web.Controllers
{
public class AccountController : Controller
{
public void SignIn()
{
if (!Request.IsAuthenticated)
{
// Signal OWIN to send an authorization request to Azure
Request.GetOwinContext().Authentication.Challenge(
new AuthenticationProperties { RedirectUri = "/" },
OpenIdConnectAuthenticationDefaults.AuthenticationType);
}
}
public ActionResult SignOut()
{
if (Request.IsAuthenticated)
{
var tokenStore = new SessionTokenStore(null,
System.Web.HttpContext.Current, ClaimsPrincipal.Current);
tokenStore.Clear();
Request.GetOwinContext().Authentication.SignOut(
CookieAuthenticationDefaults.AuthenticationType);
}
return RedirectToAction("Index", "Home");
}
}
}
그리고 OWIN 컨텍스트를 얻는 줄에서 다음 오류가 발생합니다.
오류 CS0012 'IOwinContext'형식이 참조되지 않는 어셈블리에 정의되어 있습니다. 어셈블리 'Microsoft.Owin, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'에 대한 참조를 추가해야합니다.
하지만 이미 Microsoft.Owin
NuGet에서 최신 버전이 설치되어 있습니다. 왜 그것을 사용할 수 없습니까? 다른 NuGet 패키지의 종속성으로 인해 2.0.0.0으로 다운 그레이드 할 수 없습니다.
최신 버전을 사용하고 싶다고 Visual Studio에 알리려면 어떻게 Microsoft.Owin
해야합니까?
나는 그것을 알아 냈다고 생각합니다-이전에 내 csproj 파일의 변경 사항을 되돌 렸기 때문에 Microsoft.Owin
패키지가 림보에 붙어 NuGet에 따라 설치되었지만 내 csproj 파일에 따라 설치되지 않았습니다. 강제로 설치하려면 이전 버전으로 전환 한 다음 다시 전환해야했습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다