0

I'm not really sure about this question but is there a way to protect against tampered/missing QueryStrings in ASP.NET?

Example: I have this URL

http://localhost:56842/TCKT/Configs.aspx?type=view

From Code Behind I'm getting the value like below:

Request.QueryString["type"];

I know how to protect against missing values but I need to find out if there is a way to protect against missing QueryString meaning

?type=

Is missing all together.

I have seen people doing

Request.QueryString["type"].IsEmpty()

But is not working for me and I'm not really sure if this is possible. Any help you could provide will be really appreciated.

jorame
  • 2,147
  • 12
  • 41
  • 58

2 Answers2

0
String.IsNullOrEmpty(Request.QueryString["type"]);

Somewhat similar for specific types

Community
  • 1
  • 1
Ross Bush
  • 14,648
  • 2
  • 32
  • 55
0
string type = Request.QueryString["type"] ?? "default"

To get the value or default when the value is null.

rumburak
  • 1,097
  • 11
  • 19