I need to design a WS that will after authenicating the user, create a cookie
on the users PC that made the request. All the code I keep finding is how to
get a WS to read a cookie, I need it to create one. The below code doesnt add
the cookie to my cache. However if I place this in an non asmx page its fine
Any help you offer is apperiated
[WebMethod(Enabl eSession=true)]
public string CreateToken(str ing User, string App, string County)
{
//Do some stuff
....
....
HttpCookie myCookie = new HttpCookie("Nam eMaster");
myCookie.Domain = "mydomain.c om";
myCookie["ID"] = Result.ToString ();
myCookie["User"] = User;
myCookie["App"] = App;
myCookie["County"] = County;
myCookie.Expire s = DateTime.Now.Ad dMinutes(30);
HttpContext.Cur rent.Response.C ookies.Add(myCo okie); //doesnt work
--
JP
..NET Software Developer 7 1988
Hi JP,
HttpContext.Cur rent.Response.C ookies.Add(myCo okie); //doesnt work
What do you mean it doesn't work? Do you get an error, or you're just not
seeing the Cookie on the successive request for the next the Web Service
method? If the latter, you ned to set up your WS Proxy on the client to
handle cookies. We enventually settled on using SOAP header, rather than a
cookie, so I don't have live code to demonstrate this, but if I recall
correctly, you need to code something like
m_WSProxyClass. CookieContainer = new System.Net.Cook ieContainer();
So that your proxy will now have access to cookies for the purpose of
receiving and sending.
If this doesn't do it for you, I will see if I can dig up some old code from
when we were using cookies. We did manage to get it to work and so should
you.
Standard caveat applies: If your Web Services are going to rely on coookies,
you will be limited to HTTP clients. Other clients which don't support the
cookie mechanism won't be able to use your services.
Hope this helps,
Joseph Geretz
"JP" <JP@discussions .microsoft.comw rote in message
news:77******** *************** ***********@mic rosoft.com...
>I need to design a WS that will after authenicating the user, create a cookie
on the users PC that made the request. All the code I keep finding is how
to
get a WS to read a cookie, I need it to create one. The below code doesnt
add
the cookie to my cache. However if I place this in an non asmx page its
fine
Any help you offer is apperiated
[WebMethod(Enabl eSession=true)]
public string CreateToken(str ing User, string App, string County)
{
//Do some stuff
...
...
HttpCookie myCookie = new HttpCookie("Nam eMaster");
myCookie.Domain = "mydomain.c om";
myCookie["ID"] = Result.ToString ();
myCookie["User"] = User;
myCookie["App"] = App;
myCookie["County"] = County;
myCookie.Expire s = DateTime.Now.Ad dMinutes(30);
HttpContext.Cur rent.Response.C ookies.Add(myCo okie); //doesnt work
--
JP
.NET Software Developer
my apoligies for not clarifying. The code does not error out. I just dont get
the cookie in my cache.
--
JP
..NET Software Developer
"Joseph Geretz" wrote:
Hi JP,
HttpContext.Cur rent.Response.C ookies.Add(myCo okie); //doesnt work
What do you mean it doesn't work? Do you get an error, or you're just not
seeing the Cookie on the successive request for the next the Web Service
method? If the latter, you ned to set up your WS Proxy on the client to
handle cookies. We enventually settled on using SOAP header, rather than a
cookie, so I don't have live code to demonstrate this, but if I recall
correctly, you need to code something like
m_WSProxyClass. CookieContainer = new System.Net.Cook ieContainer();
So that your proxy will now have access to cookies for the purpose of
receiving and sending.
If this doesn't do it for you, I will see if I can dig up some old code from
when we were using cookies. We did manage to get it to work and so should
you.
Standard caveat applies: If your Web Services are going to rely on coookies,
you will be limited to HTTP clients. Other clients which don't support the
cookie mechanism won't be able to use your services.
Hope this helps,
Joseph Geretz
"JP" <JP@discussions .microsoft.comw rote in message
news:77******** *************** ***********@mic rosoft.com...
I need to design a WS that will after authenicating the user, create a
cookie
on the users PC that made the request. All the code I keep finding is how
to
get a WS to read a cookie, I need it to create one. The below code doesnt
add
the cookie to my cache. However if I place this in an non asmx page its
fine
Any help you offer is apperiated
[WebMethod(Enabl eSession=true)]
public string CreateToken(str ing User, string App, string County)
{
//Do some stuff
...
...
HttpCookie myCookie = new HttpCookie("Nam eMaster");
myCookie.Domain = "mydomain.c om";
myCookie["ID"] = Result.ToString ();
myCookie["User"] = User;
myCookie["App"] = App;
myCookie["County"] = County;
myCookie.Expire s = DateTime.Now.Ad dMinutes(30);
HttpContext.Cur rent.Response.C ookies.Add(myCo okie); //doesnt work
--
JP
.NET Software Developer
Users (progrmmers) will use this service to create a GUID. This GUID along
with other related information will be stored in a cookie on local machine so
that our application can authenicate admin requests using the cookie
information. This is why the cookie is only valid for 30 mins per request
--
JP
..NET Software Developer
"Joseph Geretz" wrote:
Hi JP,
HttpContext.Cur rent.Response.C ookies.Add(myCo okie); //doesnt work
What do you mean it doesn't work? Do you get an error, or you're just not
seeing the Cookie on the successive request for the next the Web Service
method? If the latter, you ned to set up your WS Proxy on the client to
handle cookies. We enventually settled on using SOAP header, rather than a
cookie, so I don't have live code to demonstrate this, but if I recall
correctly, you need to code something like
m_WSProxyClass. CookieContainer = new System.Net.Cook ieContainer();
So that your proxy will now have access to cookies for the purpose of
receiving and sending.
If this doesn't do it for you, I will see if I can dig up some old code from
when we were using cookies. We did manage to get it to work and so should
you.
Standard caveat applies: If your Web Services are going to rely on coookies,
you will be limited to HTTP clients. Other clients which don't support the
cookie mechanism won't be able to use your services.
Hope this helps,
Joseph Geretz
"JP" <JP@discussions .microsoft.comw rote in message
news:77******** *************** ***********@mic rosoft.com...
I need to design a WS that will after authenicating the user, create a
cookie
on the users PC that made the request. All the code I keep finding is how
to
get a WS to read a cookie, I need it to create one. The below code doesnt
add
the cookie to my cache. However if I place this in an non asmx page its
fine
Any help you offer is apperiated
[WebMethod(Enabl eSession=true)]
public string CreateToken(str ing User, string App, string County)
{
//Do some stuff
...
...
HttpCookie myCookie = new HttpCookie("Nam eMaster");
myCookie.Domain = "mydomain.c om";
myCookie["ID"] = Result.ToString ();
myCookie["User"] = User;
myCookie["App"] = App;
myCookie["County"] = County;
myCookie.Expire s = DateTime.Now.Ad dMinutes(30);
HttpContext.Cur rent.Response.C ookies.Add(myCo okie); //doesnt work
--
JP
.NET Software Developer
Hi JP,
Have a look at the Cache object. The Cache object is a server side store
with much of the same functionality as cookies have. So you can place data
in the Cache and it will expire after a certain period of time, just as a
cookie does. Instead of using a cookie to shuttle data back and forth, the
data remains on the server in the cache, keyed by GUID for example, and you
can use a SOAP header to shuttle the GUID back and forth between client and
server on each request.
Your earlier comment about not seeing the cookie in the cache is consistent
with the fact that you haven't created a cookiecontainer on the client to
maintain the cookie (see my earlier response).
Hoep this helps,
- Joseph Geretz -
"JP" <JP@discussions .microsoft.comw rote in message
news:7C******** *************** ***********@mic rosoft.com...
Users (progrmmers) will use this service to create a GUID. This GUID along
with other related information will be stored in a cookie on local machine
so
that our application can authenicate admin requests using the cookie
information. This is why the cookie is only valid for 30 mins per request
--
JP
.NET Software Developer
"Joseph Geretz" wrote:
>Hi JP,
HttpContext.Cur rent.Response.C ookies.Add(myCo okie); //doesnt work
What do you mean it doesn't work? Do you get an error, or you're just not seeing the Cookie on the successive request for the next the Web Service method? If the latter, you ned to set up your WS Proxy on the client to handle cookies. We enventually settled on using SOAP header, rather than a cookie, so I don't have live code to demonstrate this, but if I recall correctly, you need to code something like
m_WSProxyClass .CookieContaine r = new System.Net.Cook ieContainer();
So that your proxy will now have access to cookies for the purpose of receiving and sending.
If this doesn't do it for you, I will see if I can dig up some old code from when we were using cookies. We did manage to get it to work and so should you.
Standard caveat applies: If your Web Services are going to rely on coookies, you will be limited to HTTP clients. Other clients which don't support the cookie mechanism won't be able to use your services.
Hope this helps,
Joseph Geretz
"JP" <JP@discussions .microsoft.comw rote in message news:77******* *************** ************@mi crosoft.com...
>I need to design a WS that will after authenicating the user, create a cookie
on the users PC that made the request. All the code I keep finding is
how
to
get a WS to read a cookie, I need it to create one. The below code
doesnt
add
the cookie to my cache. However if I place this in an non asmx page its
fine
Any help you offer is apperiated
[WebMethod(Enabl eSession=true)]
public string CreateToken(str ing User, string App, string County)
{
//Do some stuff
...
...
HttpCookie myCookie = new HttpCookie("Nam eMaster");
myCookie.Domain = "mydomain.c om";
myCookie["ID"] = Result.ToString ();
myCookie["User"] = User;
myCookie["App"] = App;
myCookie["County"] = County;
myCookie.Expire s = DateTime.Now.Ad dMinutes(30);
HttpContext.Cur rent.Response.C ookies.Add(myCo okie); //doesnt work
--
JP
.NET Software Developer
"Joseph Geretz" <jg*****@nospam .comwrote in message
news:eQ******** *****@TK2MSFTNG P06.phx.gbl...
Hi JP,
....
Standard caveat applies: If your Web Services are going to rely on
coookies, you will be limited to HTTP clients. Other clients which don't
support the cookie mechanism won't be able to use your services.
In fact, not all HTTP clients will support cookies.
Depending on what you mean to use the cookie for, you might do better with a
SOAP header.
John
Cookies are created by the client (browser). As such, it wouldn't make any
sense for a web service to attempt to create a cookie because it is one step
removed from the correct source for cookies, the web server.
Client ---web page --a web service
See how the service is not the right place for this. The code to create the
cookie should be in the page/code that calls the cookie.
"JP" <JP@discussions .microsoft.comw rote in message
news:77******** *************** ***********@mic rosoft.com...
>I need to design a WS that will after authenicating the user, create a cookie
on the users PC that made the request. All the code I keep finding is how
to
get a WS to read a cookie, I need it to create one. The below code doesnt
add
the cookie to my cache. However if I place this in an non asmx page its
fine
Any help you offer is apperiated
[WebMethod(Enabl eSession=true)]
public string CreateToken(str ing User, string App, string County)
{
//Do some stuff
...
...
HttpCookie myCookie = new HttpCookie("Nam eMaster");
myCookie.Domain = "mydomain.c om";
myCookie["ID"] = Result.ToString ();
myCookie["User"] = User;
myCookie["App"] = App;
myCookie["County"] = County;
myCookie.Expire s = DateTime.Now.Ad dMinutes(30);
HttpContext.Cur rent.Response.C ookies.Add(myCo okie); //doesnt work
--
JP
.NET Software Developer
Correction:
The code to create the
cookie should be in the page/code that calls the *service*.
"Scott M." <s-***@nospam.nosp amwrote in message
news:Or******** ******@TK2MSFTN GP05.phx.gbl...
Cookies are created by the client (browser). As such, it wouldn't make
any sense for a web service to attempt to create a cookie because it is
one step removed from the correct source for cookies, the web server.
Client ---web page --a web service
See how the service is not the right place for this. The code to create
the cookie should be in the page/code that calls the cookie.
"JP" <JP@discussions .microsoft.comw rote in message
news:77******** *************** ***********@mic rosoft.com...
>>I need to design a WS that will after authenicating the user, create a cookie on the users PC that made the request. All the code I keep finding is how to get a WS to read a cookie, I need it to create one. The below code doesnt add the cookie to my cache. However if I place this in an non asmx page its fine
Any help you offer is apperiated
[WebMethod(Enabl eSession=true)] public string CreateToken(str ing User, string App, string County) { //Do some stuff ... ...
HttpCookie myCookie = new HttpCookie("Nam eMaster"); myCookie.Domai n = "mydomain.c om"; myCookie["ID"] = Result.ToString (); myCookie["User"] = User; myCookie["App"] = App; myCookie["County"] = County; myCookie.Expir es = DateTime.Now.Ad dMinutes(30); HttpContext.Cu rrent.Response. Cookies.Add(myC ookie); //doesnt work -- JP .NET Software Developer
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: P. Obbard |
last post by:
Hi all,
How can I create a privacy policy for a cookie? I have an invisible image
loading on a 3rd-party hosted site to help me watch traffic, but the cookie
I'm using is being rejected by IE6 browsers on their default Security
setting because I lack a privacy policy.
How can I add a privacy policy to the cookie I'm creating (with ASP)?
Thanks!
|
by: Rich |
last post by:
Hello,
I want to create a cookie that will expire in a few
mintues after a user leaves my page so that they can
return without having to login again if they were only
gone for a few minutes. I tried putting this code in the
Page_Unload event but got an error message that cookies
not supported here.
....
Sub Page_Unload 'this not working here
|
by: Francois |
last post by:
Is it possible to automatically create an array on load page?
I want my script to be external.
(<script language="JavaScript" src="somescript.js"></script>)
Several pages should use this script. I have an unknown number of <DIV>
elements in each page, all with a unique id (ID="name"). I need an array
with all the names of these div-elements in it, the order is unimportant.
Can someone help me out here?
|
by: raghavendra |
last post by:
How to create a server-side cookie using C#
|
by: Aah |
last post by:
here is my code which is use to create a cookie
for some reason when I use the domain property I am not able to see the
cookie in my cookies folder.
But when I comment out my domain property, I can see my cookie in my cookies
folder.
How can I use the domain property to create a cookie????
Dim MyCookie As New HttpCookie("firstcookie")
Dim now As DateTime = DateTime.Now
| |
by: Jason Shohet |
last post by:
Our network guys want to create a txt file on everyone's machine in our
company, that I can pick up as a cookie in ASP.NET. ie,
Request.Cookies
But I don't know what to tell them -- which folder to put the txt file in, &
how to name it! Working backwards, it looks like my .NET cookies are stored
in c:\Documents and Settings\shohetj\Cookies
and a .NET cookie is named, ie shohetj@153.5.80.txt
But I still don't know what to tell...
|
by: joun |
last post by:
Hi all,
i want to create in my asp.net application a custom server variable, so i
can retrieve later in other pages (even asp or perl) with
request.servervariables("HTTP_mycustomvariable")
i've tried with response.appendheader("mycustomvariable", "somevalue") but
this doesn't work, or the variable scope is limited to aspx files, not asp
or perl.
So there is a solution with my problem, event with a external vc++ program?
|
by: doihe |
last post by:
Hi.
I use VB.NET to create a soft which POST data in a website writed
in PHP. First, I must to login in this website with a username and
a password.
After, I must use this cookie to post, to naviguate in this site.
Can I write a cookie in LOCAL (with cookie's value : username,
password, path , time expire...) and use this cookie in order to
POST in this website ? The website can accept my cookie ?
|
by: Alessandro Fachin |
last post by:
Hi, i am trying to forge a new cookie by own with cookielib. But i don't
still have success. This a simply code:
import cookielib, urllib, urllib2
login = 'Ia am a cookie!'
cookiejar = cookielib.CookieJar()
urlOpener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
values = {'user':login}
data = urllib.urlencode(values)
request = urllib2.Request("http://localhost/cookie.php", data)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |