开发者

asp.net cookie from a resource project (+ a general info)

开发者 https://www.devze.com 2022-12-11 23:47 出处:网络
i\'d like to use a class to manage a certain cookie, but not directly on the page where i have access to all the httpcookie stuff like so HttpContext.Current.Request.Cookies[\"CookieName\"].Value;.

i'd like to use a class to manage a certain cookie, but not directly on the page where i have access to all the httpcookie stuff like so HttpContext.Current.Request.Cookies["CookieName"].Value;.

however i'd like to be able to do this from a class in another project. i have a reference to that project and can access the class, but there i do not have access to the httpcontext.

so how do i get access to that, and how can i generally access all the stuff in an outside class that i can on t开发者_Go百科he page directly?

the reason for this is that this code is common and will be used on a lot of pages, so don't want to have it in multiple places.

thnx

i hope i explained it correctly, ask if you need more info.


Add the System.Web assembly reference to your class library project and use:

System.Web.HttpContext.Current to get access to the HttpContext, from within any of your classes in your library.

0

精彩评论

暂无评论...
验证码 换一张
取 消