Getting a Request.Headers value

后端 未结 7 1070
忘了有多久
忘了有多久 2020-12-01 07:33

Very simple I\'m sure, but driving me up the wall! There is a component that I use in my web application that identifies itself during a web request by adding the header \"X

7条回答
  •  臣服心动
    2020-12-01 08:18

    The following code should allow you to check for the existance of the header you're after in Request.Headers:

    if (Request.Headers.AllKeys.Contains("XYZComponent"))
    {
        // Can now check if the value is true:
        var value = Convert.ToBoolean(Request.Headers["XYZComponent"]);
    }
    

提交回复
热议问题