Asp.Net WebAPI에서 쿠키 획득 방법

1310 단어
1.
/// <summary>
///        cookie
/// </summary>
/// <returns></returns>
[HttpGet]
[HttpPost]
public string GetOne()
{
    //1. WebApi       cookie     
    //2. WebApi        Form,QueryString         
    HttpCookieCollection collection= HttpContext.Current.Request.Cookies;

    //1.    context,   cookie     
    HttpContextBase baseContext = (HttpContextBase)Request.Properties["MS_HttpContext"];
    HttpCookieCollection cookie2 = baseContext.Request.Cookies;


    //2.api        cooki   
    Collection<CookieHeaderValue> cookieValues= Request.Headers.GetCookies();


    return CookieHelper.GetString("username");
}

 
api의 쿠키 사용 설명:
http://www.asp.net/web-api/overview/advanced/http-cookies

좋은 웹페이지 즐겨찾기