By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

Connect to session

P: n/a
Hi.
How can I join session or read Session variables if I have the SessionID
(or anything what I can supply)?

Imagine I have a external link from my webpages, which opens an application
which is expected to make requests to the server. It starts another session,
but I need to use the session from browser.
To the link I'm able to send any property the server can give me.

Thanks, Jan.
May 7 '06 #1
Share this Question
Share on Google+
17 Replies


P: n/a
what a confusion you said !!!
can you simplefy what you need?

if you have website A and website B, if not in the same server they will
have diferent sessions (even if using the same name)

to send info from website A to website B use the POST or GET and them
populate the new website with the values.

example to send session("name") and session("username") from website A to
website B
website A

session("name") = "Bruno"
session("username") = "balexandre"

the link to open the new website B if you're using GET method sould be like
this

www.domainB.com/websiteBpage.aspx?un= & session("username") & "&n=" &
session("name")

in website B populate the sessions using the QueryString method

session("name") = request.querystring("n")
session("username") = request.querystring("un")

--

Bruno Alexandre
(a Portuguese in Denmark)

"Jan Kucera" <ua*@centrum.cz> escreveu na mensagem
news:e1*************@TK2MSFTNGP05.phx.gbl...
Hi.
How can I join session or read Session variables if I have the SessionID
(or anything what I can supply)?

Imagine I have a external link from my webpages, which opens an
application which is expected to make requests to the server. It starts
another session, but I need to use the session from browser.
To the link I'm able to send any property the server can give me.

Thanks, Jan.

May 7 '06 #2

P: n/a
Okay sorry if I made a big confusion to you ! :-)

So. Firstly I have only one site. I will make concrete examples with the
real situation I have, I just thought it will complicate everything.

User logs into the web using Windows authentication. On the web, he opens a
project. Each user has CurrentProject variable in his Session.
Now, on some page, there is link to a Word document. The Word document opens
and -using macro- is about to update its content from CurrentProject at the
web server.
I have handler/web service published to return values to the document, for
example http://myserver/getcontent.ashx. However, Word starts new session
with its request.

And thats it. At the handler I need to get the CurrentProject but I don't
have the session into which the user logged in.

I thought that I could send I don't know eg. SessionID, so the Word can ask
for http://myserver/getcontent.ashx?SessionID=id, and on the server side, I
can get the proper session and its CurrentProject.

I have no control of the request stream (thus headers) from the Word.

Is that somewhat clearer?
Jan
May 7 '06 #3

P: n/a
V
Hi Jan,

Word will always act like a new client and hence will start a new
session. I am not too sure if you can re-use a session in teh way that
you are visualizing it or not, but here is a work around:

Create a session table in the database. This way, what you can do is
when a user logs in, you can make an entry of the session (and
associated variables) in the database. Now you can pass the SessionID
or the UserID to your word document, which can pass it on to the web
service through its macro. The web service can then recreate the
session from the database.

I hope that helped.

Regards,
Vaibhav

May 7 '06 #4

P: n/a
now I know what you need, but that's WORD programming issue

try to add this question in microsoft.public.word.programming newsgroup,
maybe they will responde to u better that the folhs in this NG

--

Bruno Alexandre
(a Portuguese in Denmark)

"Jan Kucera" <ua*@centrum.cz> escreveu na mensagem
news:uJ**************@TK2MSFTNGP05.phx.gbl...
Okay sorry if I made a big confusion to you ! :-)

So. Firstly I have only one site. I will make concrete examples with the
real situation I have, I just thought it will complicate everything.

User logs into the web using Windows authentication. On the web, he opens
a project. Each user has CurrentProject variable in his Session.
Now, on some page, there is link to a Word document. The Word document
opens and -using macro- is about to update its content from CurrentProject
at the web server.
I have handler/web service published to return values to the document, for
example http://myserver/getcontent.ashx. However, Word starts new session
with its request.

And thats it. At the handler I need to get the CurrentProject but I don't
have the session into which the user logged in.

I thought that I could send I don't know eg. SessionID, so the Word can
ask for http://myserver/getcontent.ashx?SessionID=id, and on the server
side, I can get the proper session and its CurrentProject.

I have no control of the request stream (thus headers) from the Word.

Is that somewhat clearer?
Jan

May 7 '06 #5

P: n/a
Actually not, this is not Word issue at all and reason why I didn't talked
about Word before.

So what I need is a collection of Session objects for Application,
accessable by SessionID as a key...

I need something like Session = Application.Sessions[mySessionID];

By the way, how do I find current session count and iterate over them?
"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:ey**************@TK2MSFTNGP05.phx.gbl...
now I know what you need, but that's WORD programming issue

try to add this question in microsoft.public.word.programming newsgroup,
maybe they will responde to u better that the folhs in this NG

--

Bruno Alexandre
(a Portuguese in Denmark)

"Jan Kucera" <ua*@centrum.cz> escreveu na mensagem
news:uJ**************@TK2MSFTNGP05.phx.gbl...
Okay sorry if I made a big confusion to you ! :-)

So. Firstly I have only one site. I will make concrete examples with the
real situation I have, I just thought it will complicate everything.

User logs into the web using Windows authentication. On the web, he opens
a project. Each user has CurrentProject variable in his Session.
Now, on some page, there is link to a Word document. The Word document
opens and -using macro- is about to update its content from
CurrentProject at the web server.
I have handler/web service published to return values to the document,
for example http://myserver/getcontent.ashx. However, Word starts new
session with its request.

And thats it. At the handler I need to get the CurrentProject but I don't
have the session into which the user logged in.

I thought that I could send I don't know eg. SessionID, so the Word can
ask for http://myserver/getcontent.ashx?SessionID=id, and on the server
side, I can get the proper session and its CurrentProject.

I have no control of the request stream (thus headers) from the Word.

Is that somewhat clearer?
Jan


May 7 '06 #6

P: n/a
You don't. I don't believe that is supported in ASP.NET
not unless you manage your own providers and keep
track of them in your own code.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
Earn money answering .NET questions
http://www.eggheadcafe.com/forums/merit.asp

"Jan Kucera" <ua*@centrum.cz> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Actually not, this is not Word issue at all and reason why I didn't talked
about Word before.

So what I need is a collection of Session objects for Application,
accessable by SessionID as a key...

I need something like Session = Application.Sessions[mySessionID];

By the way, how do I find current session count and iterate over them?
"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:ey**************@TK2MSFTNGP05.phx.gbl...
now I know what you need, but that's WORD programming issue

try to add this question in microsoft.public.word.programming newsgroup,
maybe they will responde to u better that the folhs in this NG

--

Bruno Alexandre
(a Portuguese in Denmark)

"Jan Kucera" <ua*@centrum.cz> escreveu na mensagem
news:uJ**************@TK2MSFTNGP05.phx.gbl...
Okay sorry if I made a big confusion to you ! :-)

So. Firstly I have only one site. I will make concrete examples with the
real situation I have, I just thought it will complicate everything.

User logs into the web using Windows authentication. On the web, he
opens a project. Each user has CurrentProject variable in his Session.
Now, on some page, there is link to a Word document. The Word document
opens and -using macro- is about to update its content from
CurrentProject at the web server.
I have handler/web service published to return values to the document,
for example http://myserver/getcontent.ashx. However, Word starts new
session with its request.

And thats it. At the handler I need to get the CurrentProject but I
don't have the session into which the user logged in.

I thought that I could send I don't know eg. SessionID, so the Word can
ask for http://myserver/getcontent.ashx?SessionID=id, and on the server
side, I can get the proper session and its CurrentProject.

I have no control of the request stream (thus headers) from the Word.

Is that somewhat clearer?
Jan



May 7 '06 #7

P: n/a
Once u have sessionID , Try setting ASPNET cookie in your
application's process by Wininet call ( InternetSetCookie )

Nirmal

Jan Kucera wrote:
Hi.
How can I join session or read Session variables if I have the SessionID
(or anything what I can supply)?

Imagine I have a external link from my webpages, which opens an application
which is expected to make requests to the server. It starts another session,
but I need to use the session from browser.
To the link I'm able to send any property the server can give me.

Thanks, Jan.


May 7 '06 #8

P: n/a
Isn't that something like storing session in db?

I understand the reason why there is new session and I know how and am able
to pass session or user id to the link.

However I store quite complex and not serializable types in session. And,
this would create two concurrent sessions, which will not be synchronized.
This is bad for me.

But thanks for the idea.
Jan
May 7 '06 #9

P: n/a
So am I free to store a HttpSession array in Application object? How
expensive would be that?

"Robbe Morris [C# MVP]" <in**@eggheadcafe.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
You don't. I don't believe that is supported in ASP.NET
not unless you manage your own providers and keep
track of them in your own code.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
Earn money answering .NET questions
http://www.eggheadcafe.com/forums/merit.asp

"Jan Kucera" <ua*@centrum.cz> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Actually not, this is not Word issue at all and reason why I didn't
talked about Word before.

So what I need is a collection of Session objects for Application,
accessable by SessionID as a key...

I need something like Session = Application.Sessions[mySessionID];

By the way, how do I find current session count and iterate over them?
"Bruno Alexandre" <br*******@filtrarte.com> wrote in message
news:ey**************@TK2MSFTNGP05.phx.gbl...
now I know what you need, but that's WORD programming issue

try to add this question in microsoft.public.word.programming newsgroup,
maybe they will responde to u better that the folhs in this NG

--

Bruno Alexandre
(a Portuguese in Denmark)

"Jan Kucera" <ua*@centrum.cz> escreveu na mensagem
news:uJ**************@TK2MSFTNGP05.phx.gbl...
Okay sorry if I made a big confusion to you ! :-)

So. Firstly I have only one site. I will make concrete examples with
the real situation I have, I just thought it will complicate
everything.

User logs into the web using Windows authentication. On the web, he
opens a project. Each user has CurrentProject variable in his Session.
Now, on some page, there is link to a Word document. The Word document
opens and -using macro- is about to update its content from
CurrentProject at the web server.
I have handler/web service published to return values to the document,
for example http://myserver/getcontent.ashx. However, Word starts new
session with its request.

And thats it. At the handler I need to get the CurrentProject but I
don't have the session into which the user logged in.

I thought that I could send I don't know eg. SessionID, so the Word can
ask for http://myserver/getcontent.ashx?SessionID=id, and on the server
side, I can get the proper session and its CurrentProject.

I have no control of the request stream (thus headers) from the Word.

Is that somewhat clearer?
Jan



May 7 '06 #10

P: n/a
V
Hi Jan,

I was looking up on how to solve your problem, and came across a link
which states something that might also affect your situation. Copying
from the link:

Q: How do I use session state with web services?
A: The extra trick needed is on the caller side. You have to save and
store the cookies used by the web service. See the MSDN documentation
on HttpWebClientProtocol.CookieContainer property.

However, please note if you're using proxy object to call a web service
from your page, the web service and your page cannot share the same
session state due to architecture limitation.

This can be done if you call your web service through redirect.

The link is: http://www.eggheadcafe.com/articles/20021016.asp. This
site is really good and you may want to post your problem there and you
can be sure of a decent response.

Incidentally, I am assuming that the webservice is in the same
appdomain as your web application.

Regards,
Vaibhav

May 7 '06 #11

P: n/a
Yes, I have just the asmx file in the web project I'm thinking about.

Thank you for the link, I will read through.
Jan
"V" <va*************@gmail.com> wrote in message
news:11********************@u72g2000cwu.googlegrou ps.com...
Hi Jan,

I was looking up on how to solve your problem, and came across a link
which states something that might also affect your situation. Copying
from the link:

Q: How do I use session state with web services?
A: The extra trick needed is on the caller side. You have to save and
store the cookies used by the web service. See the MSDN documentation
on HttpWebClientProtocol.CookieContainer property.

However, please note if you're using proxy object to call a web service
from your page, the web service and your page cannot share the same
session state due to architecture limitation.

This can be done if you call your web service through redirect.

The link is: http://www.eggheadcafe.com/articles/20021016.asp. This
site is really good and you may want to post your problem there and you
can be sure of a decent response.

Incidentally, I am assuming that the webservice is in the same
appdomain as your web application.

Regards,
Vaibhav

May 7 '06 #12

P: n/a
It seems the CookieContainer stuff in web service will exactly do what I
need.

Posting this also in webservices groups, so hi all.

I have a web service, which is accessed using GET protocol. I'm accessing it
using Microsoft XML, 2.0 library (this is the reason for GET), by calling
xmldoc.load(http://server/myservice.asmx/helloworld?name=Xaver).

Now, this asmx file is in the asp.net web project and I need it to use
active session. I've read (thanks to Vaibhav) that the CookieContainer can
be used to get the correct session on the server side, however... I can't
(or at least I think I can't - question to XML group) modify the request
header of Microsoft's XML parser load function. I'm afraid there is no
chance packing CookieContainer into URL, is it?

So... any idea how to call the webservice with the correct session?

Thanks,
Jan.
May 7 '06 #13

P: n/a
V
Hi Jan,

I am not even sure if what I am saying would work, but just throwing
possibilities in the air. What if you used cookieless sessions, in
which case the sessionID is passed as part of the URL. Maybe then if
you included the SessionID in the webservice URL (when called from the
word doc) the session might get re-established?

Just a thought.

Regards,
Vaibhav

May 7 '06 #14

P: n/a
I also thought about this, I would try and get know.
I read about the CookieContainer in the MSDN and it seems it will do that
work. Unfortunately if nobody says I can pass it in the URL or I can modify
the request header of MSXML2, I can't use it.
Jan

"V" <va*************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hi Jan,

I am not even sure if what I am saying would work, but just throwing
possibilities in the air. What if you used cookieless sessions, in
which case the sessionID is passed as part of the URL. Maybe then if
you included the SessionID in the webservice URL (when called from the
word doc) the session might get re-established?

Just a thought.

Regards,
Vaibhav

May 8 '06 #15

P: n/a
Well Vaibhav, I've tried it and cookieless session does not work. Even from
the browser, the session is not restored.
I will try to manually add some session id to the request header, maybe I
found how. Just for start, do you know what tags should I have in the header
to restore the session?
Thanks, Jan.

"Jan Kucera" <ua*@centrum.cz> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
I also thought about this, I would try and get know.

May 8 '06 #16

P: n/a
V
Sorry Jan,

I do not, and I will not be able to look into this problem today :(

I suddenly have a lot of work at the office. Do let me know if you
manage to solve the problem; it is an interesting problem.

I will pick it up if you still haven't solved it when i am done with my
work. Hopefully, together we may be able to solve something.

Regards,
Vaibhav

May 8 '06 #17

P: n/a
Hi Vaibhav.
Thank you very much for your item.
I did some investigation on packets and found out, that all that is sent
about the session is Set-Cookie from the server and Cookie from the IE
requests, in that form:

Cookie: ASP.NET_SessioniD=[theSessionIDreturnedBySessionObject]

Which gives me very big expectations...
However the MSXML2 which I'm using .... I'm not able to set the header with
it. I found it has a bug and the cookie header must be set twice, however
this didn't help, I see still no cookie header in the request packet. :(

(Can anybody confirm that providing valid session id in the header will get
into the session on server side? What else should be present for IIS not to
require authorization again?)

Jan.

"V" <va*************@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
Sorry Jan,

I do not, and I will not be able to look into this problem today :(

I suddenly have a lot of work at the office. Do let me know if you
manage to solve the problem; it is an interesting problem.

I will pick it up if you still haven't solved it when i am done with my
work. Hopefully, together we may be able to solve something.

Regards,
Vaibhav

May 8 '06 #18

This discussion thread is closed

Replies have been disabled for this discussion.