問題描述
任何非常熟悉 IIS 中的 FTP 7.5 可擴展性的人都知道我可能做錯了什么嗎?
Anyone pretty familiar with FTP 7.5 extensibility in IIS know what I might be doing wrong?
我在實現(xiàn) IFtpLogProvider 以正常工作以進行自定義日志記錄時遇到嚴重問題.我要做的就是將超出靜態(tài)閾值的故障記錄到事件日志中,并且每隔一段時間進行一次垃圾收集.我試過使用通用字典和提供者,但沒有運氣,現(xiàn)在即使是這個簡單的代碼我也無法工作.提供者甚至沒有在下面的代碼存根中創(chuàng)建事件日志(或者如果我事先創(chuàng)建它,則使用它).所以現(xiàn)在我很困惑.
I am having serious trouble getting an implementation of IFtpLogProvider to work correctly for custom logging. All I want to do is log failures beyond a static threshold to the event log, and have garbage collection every so often. I've tried working with a generic dictionary and the provider with no luck, and now even this simple bit of code I can't get working. The provider is not even creating the event log in the code stub below (or using it if I create it beforehand). So now I am deeply confused.
在程序集從 VS 中簽名后,我按照說明注冊程序集,我可以確認它已添加到 GAC.通過注冊自定義提供程序選項將其添加到 IIS 7.5 似乎也很好.
I follow the instructions to register the assembly after it is signed from within VS and I can confirm that it is added to the GAC. Adding it to IIS 7.5 via the Register Custom Providers option seems to be fine, too.
我們將不勝感激任何有關具體建議的幫助,因為即使使用 Robert McMurray 的優(yōu)秀教程集,我仍然遇到這些問題.順便說一句,我正在使用托管代碼的接口在 2008 R2 機器上運行它.
Any help with specific suggestions would be greatly appreciated, as even with the excellent set of tutorials by Robert McMurray I am still having these issues. I am running this on a 2008 R2 box, by the way, using the interface for managed code.
下面的存根:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration.Provider;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Diagnostics.Eventing;
using System.Text;
using Microsoft.Web.FtpServer;
using System.IO;
public class test: BaseProvider, IFtpLogProvider
{
void IFtpLogProvider.Log(FtpLogEntry loggingParameters)
{
if (!EventLog.SourceExists("TEST"))
{
EventLog.CreateEventSource("TEST", "TEST");
}
// Just trying to get anything into this log, like a list of
// USER attempts or something
EventLog.WriteEntry("TEST", loggingParameters.Command);
}
// Mark an IP address for banning.
private void BanAddress(string ipAddress)
{
EventLog.WriteEntry("TEST", ipAddress, EventLogEntryType.Warning, 9010);
}
}
推薦答案
我遇到了以下問題:
1) 我在 IIS 中注冊此程序集時的類名不正確:
1) I had an incorrect class name in my registration of this assembly in IIS:
FtpLogging.FtpLogDemo,FtpLoggingDemo,version=1.0.0.0,Culture=neutral,PublicKeyToken=
FtpLogging.FtpLogDemo,FtpLoggingDemo,version=1.0.0.0,Culture=neutral,PublicKeyToken=
2) 在注冊程序集時,我沒有嚴格遵循 Robert 的建議.我選中了該復選框,這將其保留為身份驗證提供程序,而此代碼示例不是.我改為啟用基本身份驗證,禁用匿名身份驗證(在我的情況下),并取消選中教程中提到的框 - 清除提供程序列表中的 FtpLoggingDemo 復選框."
2) I did not closely follow Robert's advice when registering the assembly. I left the checkbox checked, and this kept it as an authentication provider, which this code sample is not. I instead left basic auth enabled, disabled anonymous auth (in my case), and unchecked the box mentioned in the tutorial -- 'Clear the FtpLoggingDemo check box in the providers list.'
3) 我沒有使用 AppCmd(或直接修改 applicationHost.config 中的相應部分)來更新 applicationHost.config 中的自定義提供程序部分
3) I was not using AppCmd (or modifying the appropriate section in applicationHost.config directly) to update the custom providers section in applicationHost.config
<customFeatures>
<providers>
<add name="FtpLoggingDemo" enabled="true" />
</providers>
</customFeatures>
做這三件事解決了這個問題.
Doing these three things fixed the issue.
這篇關于IIS FTP 7.5 可擴展性(IFtpLogProvider 并將 FTP 故障記錄到事件日志中)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!