简体   繁体   中英

Capture request static file in asp.net

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

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

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

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

For example: "get http://localhost/myapp/report/report1.html "

How can I capture this request?

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.

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".

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">
  [...]

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

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.

Yes, IIS has such setting, Handler Mapping .

The setting determines with handlers would be called for different file extensions. Set the ASP.NET handler to desired extensions, and the you can use ASP.NET features ( IHttpModel and other) to capture.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM