Cookie Processing in Class Library

  • Thread starter Thread starter Fred Nelson
  • Start date Start date
F

Fred Nelson

Hi:

I'm developing a C# web application. I would like to create a class
library that can access cookies directly.

Every time that I put a "Response.Cookies" or a "Request.Cookies" in my
class library I get an error: "A get or set expressor expected".

If anyone knows of a way to read cookies in a c# class library I would
greatly appreciate your help!

Thanks very much,

Fred
 
Fred,

Request is a property exposed by the Page class, which you don't have
access to in your library classes.

What you want to do is get the current HttpContext instance through the
static Current property on the HttpContext class. This will expose the
properties you are used to (Request, Response, etc, etc).

Hope this helps.
 
Back
Top