Which is Best way to send data to aspx page, and why?
- using query string
- using session
- using cross page postback
- Something else
Thanks.
-
Depends what kind of data, and what kind of action is taken when the data is received. A query string is the simplest and most standard and most used way of sending data to the server. Next question is what method do you use POST or GET. As a general rule of thumb you can take the following: use POST when the request will cause action that changes state on the server, and use GET when you only retreive data from the server.
From Vasil -
What are you trying to achieve? More info. please
For example search form and advanced search form or multi step user registration.
From SelvirK -
It really depends greatly on your uses.
- using query string
Query string data is a good way of sending data which is not important to keep secure. It is probably the best and easiest way of passing data which users should be able to see and it isn't a problem if they try to change the querystring data. Paging data and sorting information is good here. Search parameters and user-requested info can go here pretty nicely.
- using session
Session is the best place for user-specific information which will be needed more than once while the user is using the site. It is great for information which doesn't need to be very secure, but needs to be associated with a user for the length of the user's visit to the site.
- using cross page postback
One danger with using postback is that it sends this information behind the scenes. It is a great way of passing information, but is probably not the best. Cross-page postbacks require that the next page handle the information passed to it. This creates fragile connections between pages as well as the problem that users must resend the posted data if they refresh the page. Does the page still work without the posted data?
- Something else
Cookies work, but they should never ever ever contain any information which needs to be secure. There are plenty of others which should be used at different times. You can read entire articles on each of these ways of passing data.
Tom : Keep in mind when storing something in session that you may run into problems depending on how much you store or the type of objects you are trying to store.From Brendan Enrick
0 comments:
Post a Comment