在asp.net中捕获请求静态文件 [英] Capture request static file in asp.net

查看:39
本文介绍了在asp.net中捕获请求静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用asp.net捕获和处理静态文件请求?

How can I capture and handle static file requests with asp.net?

我用 BeginRequest 尝试了"IModule"和"Global.asax",但是该请求未捕获.

I've tried the "IModule" and "Global.asax" with BeginRequest but the request is not captured.

IIS中是否有一些设置可以在asp.net中定向某些组件(IModule/Handler/Global.asax/DLL)?

Is there some setting in IIS to direct some Component (IModule / Handler / Global.asax / DLL) in asp.net?

还是通过某种方式将请求定向到使用C#制作的某些DLL?

Or some way to direct requests to some DLL made with C #?

例如:获取 http://localhost/myapp/report/report1.html "

如何捕获此请求?

我做不到,进入asp.net.

I could not do, get in asp.net.

我希望能够检查权限,能够处理文件并处理响应.

I want to be able to check the permission, and can handle the file, and handle the response.

推荐答案

在集成模式下运行应用程序池的最简单方法是告诉IIS将所有请求发送到托管处理程序".

The simplest way if you are running the Application Pool in Integrated mode is to tell IIS to send all requests to the "Managed Handlers".

在您的web.config文件中,您应该具有一个< system.webServer> 元素,该元素可能具有一个 modules 元素-将其更新为:

In your web.config you should have a <system.webServer> element which may have a modules element - update that to:

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
  [...]

有了这个,您将能够使用ASP.NET的所有标准功能,包括路径上的身份验证控制.

With that in place you'll be able to use all the standard features of ASP.NET including authentication control on paths.

请注意,这将通过您的应用程序发送所有请求,因此您还将在其中看到对 .css .js 文件的请求,因此如果您尝试尝试锁定所有内容,您将需要保持打开状态.

Note that this will send all requests through your application, so you'll see requests for .css and .js files in there as well so if you do try locking everything down you'll need to leave those open.

这篇关于在asp.net中捕获请求静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆