Enumerate all OWIN keys and values

时间:2016-07-11 19:25:32

标签: asp.net asp.net-mvc owin katana

How can you list out all OWIN keys and their values, similar to Request.ServerVariables in WebForms:

foreach(string k in Request.ServerVariables)
{
    Debug.WriteLine("{0}: {1}", k, Request.ServerVariables[k]);
}

1 个答案:

答案 0 :(得分:0)

I thought I would find this Googling but did not; the code is pretty straight forward after digging in with IntelliSense. It is based on owinContext.Environment.Keys

var owinContext = HttpContext.GetOwinContext();
foreach (string k in owinContext.Environment.Keys)
{
    Debug.WriteLine("{0}: {1}", k, owinContext.Environment[k]);
}