473,399 Members | 3,038 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,399 software developers and data experts.

UniqueID

Does anyone know how ASP .net creates session IDs? I heard ASP classic used
to use a GUID but those were too predictable and made it easy for people to
guess the next ID in the sequence, and that ASP .net uses a newer technique
instead.

I'd like to generate a unique session ID for a "ticket" but obviously I
don't want it to be predictable :-)

Pete
May 5 '06 #1
4 1251
Hi Peter,

I don't think session IDs are guaranteed to be unique, so you wouldn't want
to use that. There's also the danger of session hijacking.

Can you create your own GUID and store it in a Session variable or cookie
for each user?

Ken
"Peter Morris [Droopy eyes software]" <pe**@droopyeyes.no.com.spam> wrote in
message news:uD**************@TK2MSFTNGP02.phx.gbl...
Does anyone know how ASP .net creates session IDs? I heard ASP classic
used to use a GUID but those were too predictable and made it easy for
people to guess the next ID in the sequence, and that ASP .net uses a
newer technique instead.

I'd like to generate a unique session ID for a "ticket" but obviously I
don't want it to be predictable :-)

Pete

May 7 '06 #2
Hi Ken
I don't think session IDs are guaranteed to be unique, so you wouldn't
want to use that. There's also the danger of session hijacking.
That's exactly what I am trying to avoid.

Can you create your own GUID and store it in a Session variable or cookie
for each user?


At the moment my LogIn() method returns a Guid generated using
Guid.NewGuid(). According to a book I once read on ASP .net classic ASP
used to use this approach but apparently it is too easy to guess the next
Guid in the sequence, therefore people would log in to get their Guid and
then guess the Guid of other sessions before/after it in the sequence.

I also read that ASP .net gets around this by modifying the generated Guid
in some way (MD5 maybe?) to help prevent this from happening. I'm not
really at high risk of this kind of behaviour but still I'd like to know how
it is done so that I may implement it for future reference.
Thanks

Pete
May 7 '06 #3
You can implement your own session id methodology if you are worried about
such issues.

http://msdn2.microsoft.com/en-us/lib...idmanager.aspx

As for how the one out of the box works ...

ASP.NET does not by default use a GUID, basically it generates 16 bytes of
random data then encodes it. You can see this for yourself with reflector by
inspecting System.Web.SessionState.SessionId::Create

Cheers,

Greg Young
MVP - C#

"Peter Morris [Droopy eyes software]" <pe**@droopyeyes.no.com.spam> wrote in
message news:Ow**************@TK2MSFTNGP03.phx.gbl...
Hi Ken
I don't think session IDs are guaranteed to be unique, so you wouldn't
want to use that. There's also the danger of session hijacking.


That's exactly what I am trying to avoid.

Can you create your own GUID and store it in a Session variable or cookie
for each user?


At the moment my LogIn() method returns a Guid generated using
Guid.NewGuid(). According to a book I once read on ASP .net classic ASP
used to use this approach but apparently it is too easy to guess the next
Guid in the sequence, therefore people would log in to get their Guid and
then guess the Guid of other sessions before/after it in the sequence.

I also read that ASP .net gets around this by modifying the generated Guid
in some way (MD5 maybe?) to help prevent this from happening. I'm not
really at high risk of this kind of behaviour but still I'd like to know
how it is done so that I may implement it for future reference.
Thanks

Pete

May 8 '06 #4
A unique SessionID can be done in a lot of ways. Random numbers can
often be less "random" than you would like. I have used the
System.DateTime.Now.Ticks() with a lot of success. You can use it as a
seed for a Random number, and then hash that, or just do an MD5 hash on
the Ticks returned. Just make sure that the source is the same (ie:
the server(s)). Although the chances of your
System.DateTime.Now.Ticks() call returning the exact number is
virtually none since it is the specific millisecond count of that
particular DateTime instance. A combination of a GUID with something
as unique as the Tick is a fairly solid solution.

- John Fullmer

May 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David Whitney | last post by:
Hi, all. I'm trying to work with some client-side scripting issues with an ASP.NET application. I realize I've probably done something wrong, but at the moment it looks to me like an...
2
by: Henri | last post by:
Sorry to post so many questions but if you could tell me the difference between these 3 IDs, it would help me a lot. I don't know which one to use inside my custom control...
1
by: Kepler | last post by:
I have a custom control that is thrown onto a UserControl that is thrown onto a WebForm. Basically, I've got a scenario where if my UserControl sets an attribute on the custom control in the ascx,...
0
by: Arne | last post by:
I use page.UniqueID in my error routines. Sometimes I get a propert name in this variable, sometimes I got nothing in this variable. Howcome the variable is unreliable?
2
by: Ken Baltrinic | last post by:
Can someone explain this? I am writing an owner rendered User Control that basically wraps some functionality around a text box. This control uses client side javascript and implments...
2
by: Arne | last post by:
Is the Page ID supposed to do anything? Before service pack 1 on .net 1.1, I had a proper name of the page that I could use for a generic error routine. Now the ID is blank. The ID is also useless...
1
by: Aamir Mahmood | last post by:
Hi all, Is there a bug in the implementation of property UniqueID for radio button control. Because what I get through the UniqueID property is not what is rendered in the final html output. ...
1
by: Sam Samnah | last post by:
Sorry if this seems like a simplestic question, but what is the difference between "this.UniqueID" and "this.ClientID"? and when should either be used? I am Sam I am.
0
by: John Dalberg | last post by:
Where does a datagrid's UniqueID come from after a postback? Is it from the html table's id after replacing the underscores with ':'? John Dalberg
9
by: jason.hau | last post by:
Is there any way to alter this? I am aware that it's read only. Essentially the problem is that I have a webcontrol that dynamically creates a textbox and a requiredfieldvalidator control with the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.