Mikayil Abdullayev
Mikayil Abdullayev

Reputation: 12367

How do I write a cookie inside a static webmethod

I'm using John Culviner's jquery.filedownload plugin.

For that to work I need to write a cookie. How do I write a cookie from within a static webmethod? As Page. Response is an instance field I cannot access it from a static method.

Upvotes: 3

Views: 4261

Answers (4)

Levi Botelho
Levi Botelho

Reputation: 25214

var myCookie = new HttpCookie("CookieName");
myCookie["key"] = "val";

HttpContext.Current.Response.Cookies.Add(myCookie);

Upvotes: 7

RVD
RVD

Reputation: 37

use the ff: code:

HttpCookie objHTTPCk = HttpContext.Current.Request.Cookies.Get("Cookie name");

Upvotes: 1

GeorgesD
GeorgesD

Reputation: 1082

HttpContext.Current.Response.Cookies.Get("CookieName");

Upvotes: 1

KV Prajapati
KV Prajapati

Reputation: 94645

Use HttpContext.Current property in your WebMethod.

Upvotes: 5

Related Questions