2013-03-13 11 views
5

有没有一种通用的方式来拒绝查询字符串参数,例如在IIS 7中使用.swf文件或使用.Net?在IIS 7.5或.NET中禁止某些文件的查询参数

我们有一个第三方swf文件的应用程序,允许XSS通过调用某些查询字符串参数。因此我们希望以通用方式禁用参数。

我唯一想到的是编写一个处理程序,将文件调用重新路由到不带参数的调用。

回答

2

你并不需要一个Handler,只是一个新的IIS Rewrite规则,会匹配yourfile.swf?*并重写为yourfile.swf(明确无附加querystring) 。

喜欢的东西(没有检查):

<configuration> 
<system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="strip_querystring" patternSyntax="Wildcard" stopProcessing="true"> 
       <match url="yourfile.swf*" /> 
       <action type="Rewrite" url="yourfile.swf" appendQueryString="false" /> 
      </rule> 
     </rules> 
    </rewrite> 
</system.webServer> 

+0

这看起来像一个不错的和干净的解决方案。是否有可能匹配所有具有.swf扩展名的文件? – Mark 2013-03-13 14:37:32

+1

' 请确定它确实工作,因为我没有检查这些规则。 – haim770 2013-03-13 16:11:04

0

在Global.asax BeginRequest事件试试这个

Private Sub Global_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.BeginRequest 

     Dim httpContext As HttpContext = httpContext.Current 
     Dim request As HttpRequest = httpContext.Request 
     Dim response As HttpResponse = httpContext.Response 

     If request.QueryString.Count > 0 AndAlso request.Url.LocalPath.EndsWith(".swf", StringComparison.InvariantCultureIgnoreCase) = True Then 
      response.Redirect(request.Url.LocalPath) 
     End If 


    End Sub 
+0

感谢您的建议。我在VB很糟糕,但我明白你的建议,并已经在处理程序中做了类似的实现。我可能会改用上面提到的重写规则,因为它适合我的情况更好。 – Mark 2013-03-13 17:55:36