Click here to Skip to main content
15,904,346 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have design a windows application. I wrote a code to set cookie in windows application which set cookies after login success is as follows:
C#
HttpCookie cookie = new HttpCookie("Email");
cookie.Value = txtusername.Text;

DateTime dtNow = DateTime.Now;
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);


but it showing error on Cookies in last line[Response.Cookies.Add(cookie);]
which is :'string' does not contain a definition for 'Cookies' and no extension method 'Cookies' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)

So what I have to do to remove this error.

Thanks,
Posted
Updated 23-Mar-14 23:22pm
v2

1 solution

The problem is here:
"I have design a windows application.
...
Response.Cookies.Add(cookie);"


Windows applications do not have or use Cookies - only web sites do that.

Depending on whet you want to do, there are other ways, but most likely you need to think fairly carefully about how your application is designed: WinForms apps do not behave in any way line web sites!
 
Share this answer
 
Comments
CoderPanda 24-Mar-14 5:24am    
5ed!
Priyanka Bhawsar 24-Mar-14 5:43am    
So how I can add the value of email id in session or cookies.
OriginalGriff 24-Mar-14 5:47am    
You can't.
Windows applications do not have any concept of Session or of Cookies - they do not exist.
You need to relearn how to work - it isn't as simple as "tweak the user interface" and it'll work: it's a completely different way of thinking.

Oh, and before you ask: no, windows applications don't normally use Javascript either.
Priyanka Bhawsar 24-Mar-14 7:37am    
can we do this with htmlpage.htm or webbrowser1
OriginalGriff 24-Mar-14 7:47am    
Why?
There are better, more windows ways to do these things.
What you are trying to do is force something into a shape you are familiar with, regardless of whether that is a good thing to do or not - and it isn't!
The range of possibilities for windows apps is much, much larger, and much, much more flexible.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900