Session Object

bri189a

Senior Contributor
Joined
Sep 11, 2003
Messages
1,004
Location
VA
I'm trudging through ASP.NET. First some blunt honesty... if I had a choice I'd never to another web project... I just find applications more enjoyable, maybe because they're simpler to me, regardless though, I'm in it know and have to make the best of it.

Here's the start of the page I'm doing for my in-laws church:

http://www.autumnhaze.org/salem

Notice that it looks like crap. The buttons on the left are a user control...crappy as it may be. The events page has a data list and if you were to log in you'd have the add, edit, and delete functionality. I followed an Example from an MS book on the logging in. I put a group of allowed users in the web.config file. A database holds valid user names, passwords, and groups they belong too. In the global class in the procedure that checks the security context...can't remember the name of the event right now I pull information and reset them to be a part of whatever group they are a part of... Microsoft in their example has you at the Application_OnStart event set up a application object that will hold that information... this is were I though you would use a Session object and a Session event... but Session is not available from the global class... why is this? I would think that an application object, by it's name, would be global to all running instances on the server and therefore if I log in, anybody else who is using that application at the time would then become logged in. Secondly, is this the best way to keep people from doing events they should be? (I keep the add, edit, and delete portions missing by using the User.IsMember(group_name) function or whatever it is, and I use that same thing before any adding, editing, or deleting to make sure they didn't back door via the URL to that method.

Next thing...you know when you hit Refresh and a page will say 'data has expired do you want to re-submit?' or whatever it is, how would you check to make sure that isn't the case in ASP.NET so that somebody doesn't hit refresh and the same data doesn't get posted twice.

Also I'm using a dataset... I find this a tremendous waste of server resources, especially doing as microsoft says and saving it in a session object between posts... how do I bind a data reader to a data list through code? (I've used the wizards up to this point that generate an xsd file). I don't like using wizards, I rather code things myself, and I would think reading what I need to read and being done would be easier on the server than initializing a dataset, creating a table, creating a data adaper, then calling the update method, then iterating through all the rows to bind the information... opinions on that are welcome.

Finally, if you've done app programming primarily in the past (and could whip out (complicated) programs without blinking twice) and were thrown into ASP.NET and are finding the transition a lot more difficult that it should be (I mean it's fairly limited in comparission and therefore should be a snap), let me know what you did to make things come together. I just shake my head at myself that I'm having all these issues with something so simple and yet I've done some rather complicated applications in the past that seem easy in comparission.

One last thing... page validation... is there something in between on and off. Like if I leave it on and a put a less than or greater than sign you get an asp error before your code even starts. If I leave it off I have no validation what so ever unless I build it... understandable... but on somethings (like new fields) I want it off, but on others I want it on... why isn't there a Page_OnValidate method that if you use overrides the default ASP.NET validation, or is there and I just don't know about it? I mean, I've used special symbos here <> and this page doesn't crash, yet they probably don't have a function checking every possible syntax error that crashes the server running on every object on the page. ASP.NET is so frustrating to me...
 
Last edited:
Here is some explanation

bri189a said:
this is were I though you would use a Session object and a Session event... but Session is not available from the global class...
Global is... global ! Session refer to one user while Global refer to all user. If you want something for all logging user... go in Session_OnStart.

bri189a said:
Secondly, is this the best way to keep people from doing events they should be? (I keep the add, edit, and delete portions missing by using the User.IsMember(group_name) function or whatever it is, and I use that same thing before any adding, editing, or deleting to make sure they didn't back door via the URL to that method.
That seems to be a good way to proceed.

bri189a said:
Next thing...you know when you hit Refresh and a page will say 'data has expired do you want to re-submit?' or whatever it is, how would you check to make sure that isn't the case in ASP.NET so that somebody doesn't hit refresh and the same data doesn't get posted twice.
Normally... this kind of page appear when you use the Form object. Like : Response.Form or Request.Form. It's possible to add, modify and delete things in that. Depending of your <form> (if you have one), the method used might send it to the form also (if it go to Form then it won't show in the address bar.

bri189a said:
Also I'm using a dataset... I find this a tremendous waste of server resources, especially doing as microsoft says and saving it in a session object between posts... how do I bind a data reader to a data list through code? (I've used the wizards up to this point that generate an xsd file). I don't like using wizards, I rather code things myself, and I would think reading what I need to read and being done would be easier on the server than initializing a dataset, creating a table, creating a data adaper, then calling the update method, then iterating through all the rows to bind the information... opinions on that are welcome.
It's also possible of creating a command and giving him parameters so the action you want to take is done. (For your previous questions... well... I'm not too sure of myself so I better don't say anything)

bri189a said:
Finally, if you've done app programming primarily in the past (and could whip out (complicated) programs without blinking twice) and were thrown into ASP.NET and are finding the transition a lot more difficult that it should be (I mean it's fairly limited in comparission and therefore should be a snap), let me know what you did to make things come together. I just shake my head at myself that I'm having all these issues with something so simple and yet I've done some rather complicated applications in the past that seem easy in comparission.
I didn't code anything in web other than Html, Css, ASP.NET and a very little ASP 2-3 and PHP. My first and my second big job are all working in ASP.NET supported with a SQL-Server DB. But a transition from ASP (or PHP... same structure) to ASP.NET is a relatively comlicated job. Because of the CodeBehind you got way more options in doing one thing.

bri189a said:
One last thing... page validation... is there something in between on and off. Like if I leave it on and a put a less than or greater than sign you get an asp error before your code even starts. If I leave it off I have no validation what so ever unless I build it... understandable... but on somethings (like new fields) I want it off, but on others I want it on...
There is something like that... Buttons and other have a "Cause Validation" and... if you make this: Validator.Visible = false; it won't validate anymore... just like deactivating it.

bri189a said:
I mean, I've used special symbos here <> and this page doesn't crash, yet they probably don't have a function checking every possible syntax error that crashes the server running on every object on the page. ASP.NET is so frustrating to me...
Look at Server.HtmlEncode("String to encode") . It will convert "<" to the right &hexcode; and it will show correctly in your page.
 
Back
Top