Monday, March 12, 2012

Why use the context.Handler object?

According to MS this is used to retrieve public members of one web form's class from a subsequently displayed web form. Surely you could just as easily use a session variable. Pls can someone explain the difference.Session Variable's have a memory overhead. ie when used they store information in the servers memory for retrival at any time until the session has ended. I'm not saying that you are going to run out of memory, but you do need to think of the amount of data that is stored in SessionState and the number of users that are going to try to store SessionState at one time.

Session State is a very useful tool to use, however if you don't need to use it is best not to. Even better still switch Session State off in the web.config file if it is not used in your whole application, or switch it off on the pages that do not require you to get or/and set a session variable.

ViewState is the same...have you ever seen the HTML that your browser has rendered an .aspx file?


_VIEWSTATE=thfv7rtblt8gfvnkrg8676fehbrgtk8756jkblrkguyt6548q4b5438tbgfb,kgfremb5uefrgfagffaghgvi4986gfw349ygv4hgsaoiyf54fdg5fdxdfusftbfgwjh....xgfsgf etc etc

Again, if you don't need to use it, disable it. Your applications will run faster this way.

Regards,

Rog. (MCP)
Thanks for your help. It makes sense now.
Yes, that's a very good answer and one I have wondered about for a while.

Is there any way of telling what would be a limit that would inhibit performance; when should viewstate or cache be used over session or vice versa.

Sessions are easy to work with and I like to use them especially for security

i.e. ' IF Session("accessLevel") < somevalue Then
Do something....

but I have never been sure whether this is correct form.

To make sure I use both session and forms auth together??
I suspect wrongly!

regards,

J
SessionState is great I like using it too. So easy to use with all the power.

It is hard to really say what a limit would be, because it really depends on the amount of people accessing the your site at one time. It would take a lot of Data to take up 1MB and you should still have good performance.

If you are really what the best performance and still use SessionState, you can store SessionState in SQL Server instead of the inline server. This way is hard core and is best, as if anything goes wrong in the server your state information will not be lost!

ViewState only works with postbacks to the same page. ie you can not transter ViewState information between pages.

cache is used to remember information on a page even if the user closes down his/her browser and then returns later to that page (as long as it has not expired). cache information is stored on the cleint.

It is best to use Form Authentication for security as it is designed for that resson, other than SessionState. Forms Authentication is very powerful and includes many different useful tools, for example encryption.

I hope this helps,

Regards

Rog. (MCP)

0 comments:

Post a Comment