Reputation: 685
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.
Upvotes: 0
Views: 359
Reputation: 3571
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();
Upvotes: 1