views:

41

answers:

1

Hi All,

I am using silverlight unit tests to test an important part of our site. Is it possible to clear cookies before each unit test runs?

The problem is that if I do this,

HtmlPage.Document.Cookies = "";

It doesn't work. If the cookie already was this,

key = value

I can do this,

HtmlPage.Document.Cookies = "key=";

It kind of clears it out, but the string "key" is still part of the cookie.

Any ideas?

Are there any other classes in .NET that deal with cookies? The functionality seems quite limited when I am dealing with more complicated scenarios.

+2  A: 

To delete existing cookie we actually just set its expiration time to some time in the past.

Jim McCurdy wrote a few classes that make the manipulation of cookies in Silverlight easier. See his Cookies for Silverlight post. There is a handly Delete method.

DaveB