In web requests, we often need to use the page to pass values, but sometimes exceptions occur if you do not pay attention to them.
For example, the address of a page is ../index. aspx.
Its background file contains the statement for processing the passed value: if (Request. queryString ["TypeID"] = null | Request. queryString ["TypeID"]. toString () = "")
When your address.../index. aspx? If TypeID = 1, the system runs normally without any exception.
However, when your address is:
.. /Index. when aspx is used, the if (Request. queryString ["TypeID"]. toString () = "" | Request. queryString ["TypeID"]. toString () = null)
The exception occurs. What is this?
The main reason is the Request. queryString ["TypeID"] is an object that is the same as null, When you Request. queryString ["TypeID"]. toString () = "", because the Request. queryString ["TypeID"] This object does not exist at all and will not be converted to "". Therefore, when you are not sure whether there is a page value transfer, we 'd better judge whether the passed object does not exist and then process it as a string so that no exception will occur.