【问题标题】:Is there a way to protect against tampered QueryStrings or missing QueryString?有没有办法防止查询字符串被篡改或查询字符串丢失?
【发布时间】:2013-03-19 02:30:47
【问题描述】:

我不太确定这个问题,但有没有办法防止 ASP.NET 中的 QueryString 被篡改/丢失?

示例:我有这个网址

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

从后面的代码中,我得到如下值:

Request.QueryString["type"];

我知道如何防止缺少值,但我需要找出是否有办法防止缺少 QueryString 含义

?type=

一起失踪。

我见过人们这样做

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

但这对我不起作用,我不确定这是否可能。非常感谢您提供的任何帮助。

【问题讨论】:

    标签: c# asp.net .net


    【解决方案1】:
    String.IsNullOrEmpty(Request.QueryString["type"]);
    

    specific types 有点相似

    【讨论】:

    • 感谢您的帮助,非常感谢
    【解决方案2】:
    string type = Request.QueryString["type"] ?? "default"
    

    取值为null时的值或默认值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-02
      • 2018-09-22
      • 2021-12-23
      • 1970-01-01
      • 1970-01-01
      • 2013-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多