I want to add Querystring “checking” and logging in the case of any “tampered with” querystrings. Is the Page_Init event on a given page the right place to do that in the ASP.Net page lifecycle?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
My general rule is to do everything as early as possible. This might even include checking as early as Application.BeginRequest (which occurs may events before the page is even loaded), so long as query string verification is not page-dependent.
The question here is “What do you consider to be tampering?” Invalid keys? Invalid values? Attempts to encode tags that might hopefully be written to the resulting page as part of an XSS attack?
It’s hard to give any sort of specific advice without knowing more about what you’re trying to accomplish.
EDIT: To access the application events, add a Global Application Class to your project from the ‘Add New Item’ option.
Every request triggers the application lifecycle, and the page lifecycle is just a sub-process within that when the request handler happens to be an aspx file.
EDIT2: Cleaning query string data depends entirely on what you are using the data for. Some potentially dangerous uses for query string data include:
ID values: If you are using the query string to store ID values, a user could replace those with others in at attempt to access information about things they shouldn’t see, an example of which may be:
http://domain.com/somepage.aspx?userid=1343243
The user makes an educated guess and changes this to:
And that could bring up the admin user.