我試圖在IIS 7.0中的httpmodulle中設置一個servervariable(「LOGON_USER」),但我沒有實現它。在IIS 7.0中設置一個ServerVariable httpmodule
我的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中完成任何想法?
感謝