Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Using SQL to maintain session state

Author  Topic 

ajthepoolman
Constraint Violating Yak Guru

384 Posts

Posted - 2006-09-12 : 09:21:13
Hello all! I am in the beginnings of a website rewrite that is giving me a challenge that only SQL and you can help with!

Long story short, we are going to host a website internally on two load balanced servers. After my users log in, I would like to keep ahold of their security level as they browse the site. I did some reading and determined that using SQL to maintain the session state would be our best bet, even though that still opens us up to a single point of failure. But if our database is down, then the site isn't much good anyway.

I am somewhat new to web work. I did it back when it was just me and Notepad trying to make a table, but the new world with ASP.NET is something I have just started to work with. So, I am not really sure of how to go about designing the database structure for this. What kind of fields do you use to maintain session state?

If anyone can offer up any code, or point me toward a good resource, I would be most appreciative!

Thanks!

Aj

Hey, it compiles.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-09-12 : 09:46:37
http://msdn2.microsoft.com/en-US/library/ms178586.aspx



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

ajthepoolman
Constraint Violating Yak Guru

384 Posts

Posted - 2006-09-12 : 11:04:07
Oh cool! I don't have to come up with anything! Wizards can be a beautiful thing.

Thanks!

Aj

Hey, it compiles.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-09-12 : 11:21:55
yup.



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-09-12 : 11:55:08
Is that the thing that puts a reference 9 yards long in every web page burning up bandwidth like its free?

Darned bloat!

Kristen
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-09-12 : 11:59:20
only if you don't know what you're doing.
which is around 90% of all asp.net developers



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-09-12 : 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pb0J1dHRvb
l8wBThjdGwwMCRMaWJGcmFtZSRDb250ZW50UmF0aW5nMiRNdHBzX1JhdGluZ3NfUmFkaW9CdXR0b25fMQU4Y3RsMDA
kTGliRnJhbWUkQ29udGVudFJhdGluZzIkTXRwc19SYXRpbmdzX1JhZGlvQnV0dG9uXzIFOGN0bDAwJExpYkZyYW1lJ
ENvbnRlbnRSYXRpbmcyJE10cHNfUmF0aW5nc19SYWRpb0J1dHRvbl8zBThjdGwwMCRMaWJGcmFtZSRDb250ZW50UmF
0aW5nMiRNdHBzX1JhdGluZ3NfUmFkaW9CdXR0b25fNAU4Y3RsMDAkTGliRnJhbWUkQ29udGVudFJhdGluZzIkTXRwc
19SYXRpbmdzX1JhZGlvQnV0dG9uXzUFOGN0bDAwJExpYkZyYW1lJENvbnRlbnRSYXRpbmcyJE10cHNfUmF0aW5nc19
SYWRpb0J1dHRvbl82BThjdGwwMCRMaWJGcmFtZSRDb250ZW50UmF0aW5nMiRNdHBzX1JhdGluZ3NfUmFkaW9CdXR0b
25fNwU4Y3RsMDAkTGliRnJhbWUkQ29udGVudFJhdGluZzIkTXRwc19SYXRpbmdzX1JhZGlvQnV0dG9uXzj5nhA6ttH
UbNRQdVrZr7QYCfZgaQ==" />

No bloat there then! Not to mention the other wibble:

<meta name="MSHKeywordK" content="ASP.NET state management, sessions" />
<meta name="Search.MSHKeywordK" content="ASP.NET state management, sessions" />
<meta name="MSHKeywordK" content="ASP.NET Web pages, state management" />
<meta name="Search.MSHKeywordK" content="ASP.NET Web pages, state management" />
<meta name="MSHKeywordK" content="ASP.NET Web sites, state management" />
<meta name="Search.MSHKeywordK" content="ASP.NET Web sites, state management" />
<meta name="MSHKeywordK" content="ASP.NET, state management" />
<meta name="Search.MSHKeywordK" content="ASP.NET, state management" />
<meta name="MSHKeywordK" content="custom session state mode" />
<meta name="Search.MSHKeywordK" content="custom session state mode" />
<meta name="MSHKeywordK" content="default session-state mode" />
<meta name="Search.MSHKeywordK" content="default session-state mode" />
<meta name="MSHKeywordK" content="in-process session state mode" />
<meta name="Search.MSHKeywordK" content="in-process session state mode" />
<meta name="MSHKeywordK" content="session modes" />
<meta name="Search.MSHKeywordK" content="session modes" />
<meta name="MSHKeywordK" content="session state, modes" />
<meta name="Search.MSHKeywordK" content="session state, modes" />
<meta name="MSHKeywordK" content="session states, databases" />
<meta name="Search.MSHKeywordK" content="session states, databases" />
<meta name="MSHKeywordK" content="session states, modes" />
<meta name="Search.MSHKeywordK" content="session states, modes" />
<meta name="MSHKeywordK" content="session-state events, sessions" />
<meta name="Search.MSHKeywordK" content="session-state events, sessions" />
<meta name="MSHKeywordK" content="session-state modes" />
<meta name="Search.MSHKeywordK" content="session-state modes" />
<meta name="MSHKeywordK" content="SQL Server mode [.NET Framework]" />
<meta name="Search.MSHKeywordK" content="SQL Server mode [.NET Framework]" />
<meta name="MSHKeywordK" content="state management, ASP.NET" />
<meta name="Search.MSHKeywordK" content="state management, ASP.NET" />
<meta name="MSHKeywordK" content="state management, sessions" />
<meta name="Search.MSHKeywordK" content="state management, sessions" />
<meta name="MSHKeywordK" content="state server mode" />
<meta name="Search.MSHKeywordK" content="state server mode" />
<meta name="MSHKeywordK" content="state, sessions" />
<meta name="Search.MSHKeywordK" content="state, sessions" />
<meta name="MSHKeywordK" content="Web applications [.NET Framework], state management" />
<meta name="Search.MSHKeywordK" content="Web applications [.NET Framework], state management" />
<meta name="MSHKeywordK" content="Web pages [.NET Framework], state management" />
<meta name="Search.MSHKeywordK" content="Web pages [.NET Framework], state management" />
<meta name="MSHKeywordK" content="Web sites [.NET Framework], state management" />
<meta name="Search.MSHKeywordK" content="Web sites [.NET Framework], state management" />
<meta name="MSHKeywordA" content="0bb0a3a3-650f-4c47-a0c5-b08b9b591bb4" />
<meta name="Search.MSHKeywordA" content="0bb0a3a3-650f-4c47-a0c5-b08b9b591bb4" />
<meta name="MSHAttr" content="DocSetTitle:Building ASP .NET Web Applications" />
<meta name="Search.DocSetTitle" content="Building ASP .NET Web Applications" />
<meta name="MSHAttr" content="DocSetRoot:ms178586" />
<meta name="Search.DocSetRoot" content="ms178586" />
<meta name="MSHAttr" content="RevisionNumber:23" />
<meta name="Search.RevisionNumber" content="23" />
<meta name="MSHAttr" content="DevLang:aspx" />
<meta name="Search.DevLang" content="aspx" />
<meta name="MSHAttr" content="DevLang:C++" />
<meta name="Search.DevLang" content="C++" />
<meta name="MSHAttr" content="DevLang:CSharp" />
<meta name="Search.DevLang" content="CSharp" />
<meta name="MSHAttr" content="DevLang:jsharp" />
<meta name="Search.DevLang" content="jsharp" />
<meta name="MSHAttr" content="DevLang:VB" />
<meta name="Search.DevLang" content="VB" />
<meta name="MSHAttr" content="DocSet:ASPNET" />
<meta name="Search.DocSet" content="ASPNET" />
<meta name="MSHAttr" content="DocSet:ExpressLibVS" />
<meta name="Search.DocSet" content="ExpressLibVS" />
<meta name="MSHAttr" content="DocSet:NETFramework" />
<meta name="Search.DocSet" content="NETFramework" />
<meta name="MSHAttr" content="ProgModel:managed" />
<meta name="Search.ProgModel" content="managed" />
<meta name="MSHAttr" content="ShippedIn:vs.80" />
<meta name="Search.ShippedIn" content="vs.80" />
<meta name="MSHAttr" content="Technology:ASPNET" />
<meta name="Search.Technology" content="ASPNET" />
<meta name="MSHAttr" content="Technology:ManagedCode" />
<meta name="Search.Technology" content="ManagedCode" />
<meta name="MSHAttr" content="TechnologyVers:kbASPNET" />
<meta name="Search.TechnologyVers" content="kbASPNET" />
<meta name="MSHAttr" content="TopicVersion:08.00.60430.10000" />
<meta name="Search.TopicVersion" content="08.00.60430.10000" />
<meta name="MSHAttr" content="Locale:en-us" />
<meta name="Search.Locale" content="en-us" />
<meta name="MSHAttr" content="AssetID:0bb0a3a3-650f-4c47-a0c5-b08b9b591bb4" />
<meta name="Search.AssetID" content="0bb0a3a3-650f-4c47-a0c5-b08b9b591bb4" />
<meta name="MSHAttr" content="TopicType:kbArticle" />
...
<meta name="MSHAttr" content="MScategory:ms0abs99" />
<meta name="Search.MScategory" content="ms0abs99" />
<meta name="MSHAttr" content="MScategory:ms296486" />
<meta name="Search.MScategory" content="ms296486" />
<meta name="MSHAttr" content="MScategory:ywdtth2f" />
<meta name="Search.MScategory" content="ywdtth2f" />
<meta name="MSHAttr" content="MScategory:y5y3c2c5" />
<meta name="Search.MScategory" content="y5y3c2c5" />
<meta name="MSHAttr" content="MScategory:87069683" />
<meta name="Search.MScategory" content="87069683" />
<meta name="MSHAttr" content="MScategory:ms178586" />
<meta name="Search.MScategory" content="ms178586" />

Kristen
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-09-13 : 05:48:13
ok meta tags aren't bloat. they're there because it's MSDN and has to be high up on searches.

about the viewstate. viewstate is good if you know how to use it properly.
It's the basis for asp.net page postbacks. if you ask me it is a good thing.

And bandwidth... come on...




Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-09-13 : 06:23:52
"ok meta tags aren't bloat."

Every "keyword" duplicated in a second tag, and every "keyword" in its own tag? Got to be a better way to do that.

"And bandwidth... come on..."

On that one I'm absolutely serious.

Its gotten better though, but there are lots of digressions. How much straight white space in ViewSource? Look at this page for example:

66,906 bytes.

63,516 Took out the JavaScript and CSS that could be in a INCLUDE file

54,579 Took out the superfluous whitespace, comments, etc.

Looks like 20% saved to me ...

Yeah xZip, or whatever it is called, is compressing this stuff - for those servers that have bothered to turn it on. But its just the whole mental attitude to "It doesn't matter"

Our DEV servers have got progressively slower here over the last year. Nothing new installed, they are just doing basic SQL and IIS. Looks like all the service pack bloat is using more and more memory, and less and less for the apps (yes the machines are not brand new, so do not have shedloads of RAM)

MSDN is one of the slowest rendering sites I use. Way too much complicated stuff in the HTML which could be optimised easily and would a) reduce MS's bandwidth (which has to relate to cost for MS somewhere down the line as well as a performance improvement to the punter) and b) render time.

We put significant effort into optimising HTML for our clients and people say our sites are snappy, plus we need way less hardware that our competitors. Generally the real money terms of this are small, but we've also removed a lot of the complexity too, so we are saving in other areas - like making it easier to work out What's Up when something is ... errmm ... down!

</PetBeef>

Kristen
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-09-13 : 07:10:02
i agree that there's too much ugly html out there.

so my guess is that you'll be porting your stuff to .net framework 4.0 and not before that.




Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-09-13 : 07:48:24
I'll love to be using .net - but mostly to get a language with proper error handling and the ability to have some in-memory structures for caching and stuff. Most of our caching is in SQL at present, which is less efficient that having it in IIS, but VBScript Dictionary object is not really what I need for that job!

And the Error Handling in VBScript is just pants, of course ....

C# would do me just luverly! ... but we write a couple of dozen lines of ASP a year, so basically what we already have is working fine.

I could also do with being able to interpret the URL without having to have resort to a 404 handler (which is what we currently do). I'd like to be able to have urls like www.MyDomain.com/Some_English_Page_Name.EXT - can't find a way to do that in ASP, but I presume its fine in ASP.net.

All that slinky Visual Studio stuff will help me with stepping through code during debugging, but I doubt we need much of the stuff that normal ASP developers find a boon - and I can't imagine that we will embrace postback / code behind as we have established ways for tackling the problem that is designed to solve (i.e. ours is carefully tailored to how we work, rather than broad & generic)

But I know only a little about it, so I'm probably talking out of my wrong end again! Fly over, I'll buy you some beers, and you can amaze me with the technology.

Kristen
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-09-13 : 08:34:17
LOL

sure no problem.



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-09-14 : 04:02:52
quote:
I'll buy you some beers


Kristen - If you're buying I'm on my way

steve

-----------

Don't worry head. The computer will do all the thinking from now on.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-09-14 : 06:48:27
OK, what time are you both getting here? Plenty of beers in the fridge already!

Kristen
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-09-14 : 15:21:58
I'll be there in an hour

steve

-----------

Don't worry head. The computer will do all the thinking from now on.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-09-15 : 03:57:19
You're late ...
Go to Top of Page
   

- Advertisement -