本文介绍了如何启用ISAPI筛选器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

问候,

Greetings,

我想通过C#将ISAPI筛选器添加到IIS,例如php的isapi.以下部分是我的代码示例,但是我无法使其按预期运行,有什么主意吗?

I want to add an ISAPI filter into IIS by C#, for example the isapi for php. The following part is my code sample, but I couldn't make it works as it supposed to be, any idea? 

字符串 FilterName = "myFilter" ;

string FilterName = "myFilter";

字符串 FilterPath = @"C:\ iisfilts \ myfilter.dll" ;

string FilterPath = @"C:\iisfilts\myfilter.dll";

字符串 FilterDesc = 这是我的过滤器" ;

string FilterDesc = "This is my filter";

DirectoryEntry FiltersObj = DirectoryEntry ( "IIS://LocalHost/W3SVC/Filters" );

DirectoryEntry FiltersObj = new DirectoryEntry("IIS://LocalHost/W3SVC/Filters");

字符串 LoadOrder = FiltersObj.InvokeGet( "FilterLoadOrder " ).ToString();

string LoadOrder = FiltersObj.InvokeGet("FilterLoadOrder").ToString();

如果 (LoadOrder!= null )

if (LoadOrder != null)

LoadOrder = LoadOrder + ," ;

LoadOrder = LoadOrder + ",";

LoadOrder = LoadOrder + FilterName;

LoadOrder = LoadOrder + FilterName;

FiltersObj.InvokeSet( "FilterLoadOrder" 对象 [] {LoadOrder});

FiltersObj.InvokeSet("FilterLoadOrder", new Object[] {LoadOrder});

FiltersObj.Invoke( "SetInfo" null );

FiltersObj.Invoke("SetInfo", null);

DirectoryEntry FilterObj =( DirectoryEntry )FiltersObj.Invoke( 创建" 对象 [] { "IIsFilter" ,FilterName});

DirectoryEntry FilterObj = (DirectoryEntry)FiltersObj.Invoke("Create", new Object[] { "IIsFilter", FilterName });

FilterObj.Properties [ "FilterPath" ].Value = FilterPath;

FilterObj.Properties["FilterPath"].Value = FilterPath;

FilterObj.Properties [ "FilterDescription" ].Value = FilterDesc;

FilterObj.Properties["FilterDescription"].Value = FilterDesc;

FilterObj.Invoke( "SetInfo" null );

FilterObj.Invoke("SetInfo", null);

推荐答案

{

公共 无效 添加( 字符串 FilterName, 字符串 FilterPath)

public void add(string FilterName, string FilterPath)

{

DirectoryEntry FiltersObj = DirectoryEntry ( " IIS://LocalHost/W3SVC/1/Filters" );

DirectoryEntry FiltersObj = new DirectoryEntry("IIS://LocalHost/W3SVC/1/Filters");

字符串 LoadOrder = FiltersObj.InvokeGet( " FilterLoadOrder" ).ToString();

string LoadOrder = FiltersObj.InvokeGet("FilterLoadOrder").ToString();

如果 (LoadOrder!= null )

if (LoadOrder != null)

LoadOrder = LoadOrder + "," ;

LoadOrder = LoadOrder + ",";

LoadOrder = LoadOrder + FilterName;

LoadOrder = LoadOrder + FilterName;

FiltersObj.InvokeSet( " FilterLoadOrder' 新建 对象 [] {LoadOrder});

FiltersObj.InvokeSet("FilterLoadOrder", new Object[] { LoadOrder });

FiltersObj.Invoke( " SetInfo'; null );

FiltersObj.Invoke("SetInfo", null);

DirectoryEntry FilterObj =( DirectoryEntry )FiltersObj.Invoke( &; Create"; 对象 [] { " IIsFilter" ,FilterName});

DirectoryEntry FilterObj = (DirectoryEntry)FiltersObj.Invoke("Create", new Object[] { "IIsFilter", FilterName });

FilterObj.Properties [ "FilterPath" ].Value = FilterPath;

FilterObj.Properties["FilterPath"].Value = FilterPath;

FilterObj.Invoke( " SetInfo'; null );

FilterObj.Invoke("SetInfo", null);

}

}

您唯一的错误是在"iis://localhost/w3svc/1/filters"中遗漏了1;

Your only mistake was leaving out the 1 in "iis://localhost/w3svc/1/filters"


这篇关于如何启用ISAPI筛选器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 11:58