Asp.net cookieless sessionId url location

2020-04-11 19:16发布

问题:

I'm working on a mobile site where we can't rely on the phone hitting the site to have cookie support. I'm using the cookieless option for sessions and wondering if there's a way to specify where in the URL that the sessionId gets placed?

Here's what it looks like now:

http://www.somesite.com/(S(qnxbzt45h2yxpr45tj3hpr45))/Default.aspx

Is there a way to have the sessionId at the end of the url?

http://www.somesite.com/Default.aspx?S=qnxbzt45h2yxpr45tj3hpr45

回答1:

Can you not store user sessions using a Sql Database instead? I don't think you can change the sessionId position, you could try re-writing the url's but I'm not sure how that would affect .Net's handling of it

EDIT: I just remembered that the Sql option still requires a cookie on the client machine so ignore me



回答2:

Session options are set in the web.conf sessionState section. This is detailed here:

http://msdn.microsoft.com/en-us/library/h6bb9cz9(vs.71).aspx

Theres no way to setup the sessions like this with the built in session functionality of asp.net. Your best bet is to define your own session mechanism