代码之家  ›  专栏  ›  技术社区  ›  Anwar Chandra

如何确保从特定域请求帖子?

  •  1
  • Anwar Chandra  · 技术社区  · 15 年前

    HttpRequest POST 请求,并且它来自特定域?

    private bool IsRequestedFromDomain(string domain)
    {
      // Request.Form is from domain ?
      return false;
    }
    
    3 回复  |  直到 15 年前
        1
  •  1
  •   Rubens Farias    15 年前

    尝试使用

    Request.ServerVariables["HTTP_REFERER"]
    

    有关服务器变量列表,请查看: ASP ServerVariables Collection

        2
  •  1
  •   nothrow    15 年前

    唯一可以确定的方法是将一些随机生成的值发送到表单,存储到会话,然后在IsRequestedFromDomain中对其进行比较。

        3
  •  0
  •   Wim    15 年前

    使用:

    Request.UrlReferrer ,但它不可靠,因为它很容易伪造,并且可能被代理更改。