473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Connect to session

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
17 1562
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brian Pittman | last post by:
Hi all, As the subject says I'm having trouble connecting to SQL Server 2K via Visual Studio.NET 2002 (VB). It tells me that SQL Server does not exist or access is denied. I know that the...
4
tolkienarda
by: tolkienarda | last post by:
Hi all I work for a small webdesign company and we have remote hosting. i built a mysql database with phpmyadmin on the server. i then downloaded and modified a php login page. i am continuing to...
1
by: GNoter | last post by:
Scenario: I've a WebFarm with 2 web servers which are NLBs (network load balanced). Web1 and Web2; they are not part of a domain. I have a third server, Server3, which is part of a domain and on...
1
by: fbk2k5 | last post by:
hi i have a problem to connect the user inside the stored procedure in oracle i tried option CREATE OR REPLACE PROCEDURE Chk_Permission AS UserID VARCHAR2(10):='1234'; fname...
3
by: LamSoft | last post by:
I am not going to write a aspx to connect a SQL Server... but it tries to connect the SQL Server... Some of the Code.. protected void LoginButton_Click(object sender, EventArgs e) { if...
3
by: nickyeng | last post by:
i know alot of people faced this problem before. i searched google.com i search javaranch.com, no one article can help me solve the problem. I runs it in my localhost server, it runs well. But...
1
by: vibhavleo | last post by:
I am using the Microsoft Office 11.0 Object library to connect to outlook. My code is as follows: _ApplicationPtr application("Outlook.Application"); CComPtr<_NameSpace> ns;...
3
by: jc | last post by:
Hi there: Reading from internet i found that the best way to use a database is to connect and disconnect on every single database request, so if you are loading a listbox manually from a...
8
by: inpuarg | last post by:
I 'm developing a c# (.net 2.0) windows forms application and in this application i want to connect to a java servlet page (HTTPS) (which is servlet 2.4 and which may be using Web Based SSO Sun...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.