System.Net.Cookie vs System.Web.Cookie

Discussion in 'ASP .Net Security' started by william, Apr 11, 2008.

  1. william

    william Guest


    How to create System.Net.Cookie from System.Web.Cookie?


    william, Apr 11, 2008
    1. Advertisements

  2. by copying name, value and expiration time?
    Dominick Baier, Apr 14, 2008
    1. Advertisements

  3. william

    william Guest

    Hi Dominick,

    Thanks for your response.
    I've tried to copying web.cookie to net.cookie, got error "The parameter
    '{0}' cannot be an empty string.Parameter name: cookie.Domain". Here is my

    System.Net.Cookie cookie = new
    Request.Cookies[".ASPXAUTH"].Value, Request.Cookies[".ASPXAUTH"].Path,
    System.Net.CookieContainer cookies = new
    cookies.Add(cookie); //error happens here

    Any idea?


    william, Apr 14, 2008
  4. william

    william Guest


    Acturally I'm looking for sharing authcookie between web applications and
    web services. Both use Forms Authentication, and use .NET memberhsip
    framework to authenticate user.
    Senario 1. After user login to web application by providing user id and
    password, create System.Net.Cookie by current web cookie, and assign this
    cookie to web service's cookiecontainer, and call web service.
    Senario 2. I have a login.asmx web service. From web application, make a
    call to this web service to validate user, after successfully authenticated,
    I can get authcookie. I want to use this cookie for further access pages
    which are restricted only allow authenticated users.


    william, Apr 14, 2008
  5. OK - this is possible.

    Use your server name as a domain like ""

    if web app and service are in different vdirs / servers you also need to
    sync the <machineKey /> element.

    Dominick Baier (

    Developing More Secure Microsoft ASP.NET 2.0 Applications (
    Dominick Baier, Apr 14, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads