ASP.NET - Using Query Strings in order to Transfer data
There are different ways to transfer data from one page to another in ASP.NET.
Transferring information usingQuery strings is typically not recommended for reasons of security, but sometimes we have no choice but to use it.This is Particularly true in the following cases:
When we want to transfer information from a page in one site to a page located in another site;
When we want to pass information from an ASP.NET page to another page in the same site that is not written in ASP.NET.
In addition, we can use Query strings when we develop in an environment where security considerations are secondary.Such as intra-net environment or an environment where there is no meaning to permissions and security of data transferred from page to page.
The code we write on the sender would look like this:
Please note that immediately after the name of the page to which we send the information to we need to add a question mark '?'And then the name of the variable (in our case 'field1') and then an equal sign '=' and the value of the field that we send.If we want to send more data then we need to put '&' before every pair of fields and values.
The code we write in order to receive the data that was sent to a page will look like this:
'Get data from Query string
Dim sVal1 as String = Request.Querystring(Field1)
Dim sVal2 as String = Request.Querystring(Field2)
Please note: In orderto transfer data from site to site we can also useResponse.Redirect.
This article was first published in my Hebrew site for programming: www.devschool.co.il
ASP.NET - Using Query Strings in order to Transfer data