Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > System.Net.Cookie vs System.Web.Cookie

Reply
Thread Tools

System.Net.Cookie vs System.Web.Cookie

 
 
william
Guest
Posts: n/a
 
      04-11-2008
Hi,

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

THanks.

William
 
Reply With Quote
 
 
 
 
Dominick Baier
Guest
Posts: n/a
 
      04-14-2008
by copying name, value and expiration time?


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

> Hi,
>
> How to create System.Net.Cookie from System.Web.Cookie?
>
> THanks.
>
> William
>



 
Reply With Quote
 
 
 
 
william
Guest
Posts: n/a
 
      04-14-2008
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
code:

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

Any idea?

Thanks.

William
"Dominick Baier" wrote:

> by copying name, value and expiration time?
>
>
> -----
> Dominick Baier (http://www.leastprivilege.com)
>
> Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
>
> > Hi,
> >
> > How to create System.Net.Cookie from System.Web.Cookie?
> >
> > THanks.
> >
> > William
> >

>
>
>

 
Reply With Quote
 
william
Guest
Posts: n/a
 
      04-14-2008
Hi,

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.

Thanks.
William

"william" wrote:

> 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
> code:
>
> System.Net.Cookie cookie = new
> System.Net.Cookie(Request.Cookies[".ASPXAUTH"].Name,
> Request.Cookies[".ASPXAUTH"].Value, Request.Cookies[".ASPXAUTH"].Path,
> Request.Cookies[".ASPXAUTH"].Domain);
> System.Net.CookieContainer cookies = new
> System.Net.CookieContainer();
> cookies.Add(cookie); //error happens here
>
> Any idea?
>
> Thanks.
>
> William
> "Dominick Baier" wrote:
>
> > by copying name, value and expiration time?
> >
> >
> > -----
> > Dominick Baier (http://www.leastprivilege.com)
> >
> > Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
> >
> > > Hi,
> > >
> > > How to create System.Net.Cookie from System.Web.Cookie?
> > >
> > > THanks.
> > >
> > > William
> > >

> >
> >
> >

 
Reply With Quote
 
Dominick Baier
Guest
Posts: n/a
 
      04-14-2008
OK - this is possible.

Use your server name as a domain like "www.server.com"

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


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

> Hi,
>
> 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.
> Thanks.
> William
> "william" wrote:
>
>> 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
>> code:
>> System.Net.Cookie cookie = new
>> System.Net.Cookie(Request.Cookies[".ASPXAUTH"].Name,
>> Request.Cookies[".ASPXAUTH"].Value,
>> Request.Cookies[".ASPXAUTH"].Path,
>> Request.Cookies[".ASPXAUTH"].Domain);
>> System.Net.CookieContainer cookies = new
>> System.Net.CookieContainer();
>> cookies.Add(cookie); //error happens here
>> Any idea?
>>
>> Thanks.
>>
>> William
>> "Dominick Baier" wrote:
>>> by copying name, value and expiration time?
>>>
>>> -----
>>> Dominick Baier (http://www.leastprivilege.com)
>>> Developing More Secure Microsoft ASP.NET 2.0 Applications
>>> (http://www.microsoft.com/mspress/books/9989.asp)
>>>
>>>> Hi,
>>>>
>>>> How to create System.Net.Cookie from System.Web.Cookie?
>>>>
>>>> THanks.
>>>>
>>>> William
>>>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments