我正在尝试在 IIS 7.0 的 httpmodulle 中设置服务器变量(“LOGON_USER”),但我没有归档它。
到目前为止,我的 BeginRequest 函数...
BindingFlags temp = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;
MethodInfo addStatic = null;
MethodInfo makeReadOnly = null;
MethodInfo makeReadWrite = null;
Type type = application.Request.ServerVariables.GetType();
MethodInfo[] methods = type.GetMethods(temp);
foreach (MethodInfo method in methods)
{
switch (method.Name)
{
case "MakeReadWrite": makeReadWrite = method;
break;
case "MakeReadOnly": makeReadOnly = method;
break;
case "AddStatic": addStatic = method;
break;
}
}
makeReadWrite.Invoke(application.Request.ServerVariables, null);
string[] values = { "LOGON_USER", "test" };
addStatic.Invoke(application.Request.ServerVariables, values);
makeReadOnly.Invoke(application.Request.ServerVariables, null);
在我的搜索过程中,我了解到该解决方案适用于较旧的 IIS,但不适用于 IIS 7.0 或 7.5。
关于如何在 IIS 7.0 中完成的任何想法?
谢谢