0

Trying to start with VB.Net and having problem

We have such a Class in C#. How to check if cookie exist? Exactly, how to set input object "Cookie" for a function CookieExist? How to create it using GeckoFx? For example, how to find cookie with the name "Test2"?

Please, make an example.

I'm going crazy with VB.Net

P.S. I rarely write to forums if can find info on my own but VB.Net have too few examples in the net. ;/

John Saunders
  • 160,644
  • 26
  • 247
  • 397
falcon4fun
  • 25
  • 1
  • 4
  • Can you give more detail about the kind of application you're creating? – John Saunders Dec 11 '12 at 00:52
  • I'm trying to use GeckoFx and work with Gecko.CookieManager. Adding, Removing works successfully because there are no such input arguments as Cookie object. In class I gave there is a "public sealed class Cookie" but when I try to use it, it shows an error about "This class is friendly" (smth like this). – falcon4fun Dec 11 '12 at 01:09
  • For example, to print all cookies from host, I use smth like this: http://pastebin.com/v1aqhD2X Maybe, I'm wrong, but it's one of first projects. However, this works. – falcon4fun Dec 11 '12 at 01:13

1 Answers1

2

I think the code below will help you:

Dim cookieValue As String = "Value of cookie"
Dim cookieName As String = "CookieName"

Dim realCookie As HttpCookie = HttpContext.Current.Request.Cookies.Get(cookieName)
If IsNothing(realCookie) Then
    HttpContext.Current.Request.Cookies.Add(New HttpCookie(cookieName, cookieValue))
End If
abatishchev
  • 98,240
  • 88
  • 296
  • 433
Ricardo
  • 326
  • 1
  • 5
  • As I understand, This is not working with Gecko, which I posted in first post, is it? I need how to solve my issue with the Gecko.Cookie class ;/ – falcon4fun Dec 11 '12 at 01:27