I am making a email template and this template will be send to the multiple users and in this template there is only a gridview control and I will fill the grid with a session variable, Session variable is having the datatable.
My issue is this when i am using the "WebResponse" for this page then i do not get the session value that is null.(i have cross check that my session Name is same);
code Snippet:
WebRequest request = WebRequest.Create(strFullUrl);
WebResponse response = request.GetResponse();
what i am doing wrong, Please give some guidance.
By default, Sessions
does not persist with HttpWebResponse
. Create the helper class called CookieContainer
and attach it with your web request
.
CookieContainer cookieContainer = new CookieContainer();
WebRequest request = (WebRequest)WebRequest.Create(strFullUrl);
request.CookieContainer = cookieContainer;
WebResponse response = (WebResponse)request.GetResponse();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.