Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 筛选规则不适用于删除机器人程序_C#_Visual Studio_Memory Leaks_Web Config_Bots - Fatal编程技术网

C# 筛选规则不适用于删除机器人程序

C# 筛选规则不适用于删除机器人程序,c#,visual-studio,memory-leaks,web-config,bots,C#,Visual Studio,Memory Leaks,Web Config,Bots,我在我的网站上使用的内存每10分钟会在我的Windows服务器上进行一次回收,不会失败。内存通常是140mb,但突然间它会跳到600mb或更大,网站需要重新调整。我的web.config文件中有以下条目,用于阻止机器人攻击我的网站。但是,尽管我的网站使用更新后的web.config文件运行正常,但filteringRules行出现语法错误。我注意到一些机器人仍然出现在我的http日志上,我想知道我的过滤器是否工作正常。有没有人看到这段代码有问题,或者尽管我在VisualStudio中遇到语法错误

我在我的网站上使用的内存每10分钟会在我的Windows服务器上进行一次回收,不会失败。内存通常是140mb,但突然间它会跳到600mb或更大,网站需要重新调整。我的web.config文件中有以下条目,用于阻止机器人攻击我的网站。但是,尽管我的网站使用更新后的web.config文件运行正常,但filteringRules行出现语法错误。我注意到一些机器人仍然出现在我的http日志上,我想知道我的过滤器是否工作正常。有没有人看到这段代码有问题,或者尽管我在VisualStudio中遇到语法错误,这段代码是否仍能正常工作?此外,所有这些机器人会导致内存峰值吗

<requestFiltering>    
   <filteringRules>    !-- this line gives me a syntax error
    <filteringRule name="BlockSearchEngines" scanUrl="false" 
      scanQueryString="false">
        <scanHeaders>
            <clear />
            <add requestHeader="User-Agent" />
        </scanHeaders>
        <appliesTo>
            <clear />
        </appliesTo>
        <denyStrings>
            <clear />
            <add string="AhrefsBot" />
            <add string="MJ12bot" />
            <add string="ExtLinksfBot" />
            <add string="Yeti" />
            <add string="YandexBot" />
            <add string="SemrushBot" />
            <add string="DotBot" />
            <add string="istellabot" />
            <add string="Qwantify" />
            <add string="GrapeshotCrawler" />
            <add string="archive.org_bot" />
            <add string="Applebot" />
            <add string="ias_crawler" />
            <add string="Uipbot" />
            <add string="Cliqzbot" />
            <add string="TinEye-bot" />
            <add string="YandexImages" />

        </denyStrings>
    </filteringRule>
</filteringRules>

!-- 这一行给了我一个语法错误
您的
条目的语法看起来是正确的(除了结束标记的键入)

由于某些原因,Visual Studio使用的web.config架构似乎不包括
过滤器文件
。然而,该模式独立于IIS知道和做的事情,所以它不重要

此外,所有这些机器人会导致内存峰值吗

<requestFiltering>    
   <filteringRules>    !-- this line gives me a syntax error
    <filteringRule name="BlockSearchEngines" scanUrl="false" 
      scanQueryString="false">
        <scanHeaders>
            <clear />
            <add requestHeader="User-Agent" />
        </scanHeaders>
        <appliesTo>
            <clear />
        </appliesTo>
        <denyStrings>
            <clear />
            <add string="AhrefsBot" />
            <add string="MJ12bot" />
            <add string="ExtLinksfBot" />
            <add string="Yeti" />
            <add string="YandexBot" />
            <add string="SemrushBot" />
            <add string="DotBot" />
            <add string="istellabot" />
            <add string="Qwantify" />
            <add string="GrapeshotCrawler" />
            <add string="archive.org_bot" />
            <add string="Applebot" />
            <add string="ias_crawler" />
            <add string="Uipbot" />
            <add string="Cliqzbot" />
            <add string="TinEye-bot" />
            <add string="YandexImages" />

        </denyStrings>
    </filteringRule>
</filteringRules>

仅仅因为一个请求来自一个机器人,它不会占用很多内存。无意的内存峰值通常是应用程序错误——内存泄漏等。您可以使用内存分析器查看应用程序的内存使用情况。分配内存缓冲区,然后将对它们的引用存储在全局变量/集合中是一个常见的原因。未能对所有一次性对象调用
Dispose()
是另一个潜在的泄漏源。

您的代码示例没有关闭
requestFiltering
标记吗?您实际遇到了什么语法错误?我的web.config中确实有requestFiltering结束标记。我没有在代码上显示它。错误消息是我有一个无效的子元素“filteringRules”