Good Day All

I have another question. I have a Silverlight application and in one of the Silverlight pages i am hosting an Asp.net Page using a RadhtmlContainer(Telerik). I created a Cookie in Silverlight like this

public static void SetCookie(string key, string value)
        {

           // string oldCookie = HtmlPage.Document.GetProperty("cookie") as String;
            DateTime expiration = DateTime.UtcNow + TimeSpan.FromDays(2000);
            string cookie = String.Format("{0}={1};expires={2}", key, value, expiration.ToString("R"));
            HtmlPage.Document.SetProperty("cookie", cookie);
        }

and i have the same generic function to access it like this

public static string GetCookie(string key)
        {
            string[] cookies = HtmlPage.Document.Cookies.Split(';');
            key += '=';
            foreach (string cookie in cookies)
            {
                string cookieStr = cookie.Trim();
                if (cookieStr.StartsWith(key, StringComparison.OrdinalIgnoreCase))
                {
                    string[] vals = cookieStr.Split('=');

                    if (vals.Length >= 2)
                    {
                        return vals[1];
                    }

                    return string.Empty;
                }
            }

            return null;
        }

so i am trying to access this cookie in an asp.net page that is hosted on the the html Container , but i dont find the cookie.

Basically what i want to Achieve is

i want to access a value that is being created in Silverlight e.g "userid" "Username" normally i store it in the Cookie , so now i want to do a database insert , i need to do that insert from that asp.net page, but i cant get hold of that cookie value.

Thanks

for getting cookies in asp.net...use Request.Cookies("cookiesname").value

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.