GET the GET parameter in the URL. No matter what language is used to develop the website, the code is almost required. However, to obtain a URL parameter, you must first determine whether the parameter exists. If the parameter exists, the parameter is taken out. If the parameter does not exist, another value is used. This operation is called a merge operation, which is very common in JavaScript. | two vertical bars mean this. Today, I accidentally saw the merge operator in ASP. NET. What is different from JavaScript is that it is used in. NET ?? Two question marks. As a result, we immediately thought we could use it to get URL parameters, greatly streamlining the Code:
Page_Load (type = Request []? ; Keyword = Request []? ;}
Paste the previous code for comparison:
. IsNullOrEmpty (Request [? Request [. IsNullOrEmpty (Request [? Request [
In contrast, it is quite concise.
Of course, this is just a simple example. How to improve it and prevent illegal parameters in URLs must be improved in different projects. For more information, see the reference document "merge operators" in MSDN.