HttpHandler问题 [英] HttpHandler Question

查看:64
本文介绍了HttpHandler问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我写了一个HttpHandler做了一堆处理然后写了一个gif

到HttpContext。


我想做的就是让我的处理程序拦截任何请求* random.gif

我怎样才能让它工作?当然我的处理程序在我的开发机器上运行完美了...因为我把它添加到了web.config:


< add verb =" * QUOT;路径= QUOT * random.gif"类型= QUOT; Assembly.Handler" />


所以普通图像的所有请求都可以正常工作,* random.gif被我的处理程序取回了

...但是我把它放在测试服务器上它没有工作

(假设这是因为我必须添加ISAPI扩展)。因此我将
与gif扩展关联到aspnet_isapi,但随后它在

所有图像上执行(正如我预期的那样,但无论如何都尝试过)。


希望我明白我的观点。关于如何获取我的处理程序的任何建议

拦截* random.gif。

路径可以是任何来自 http://blabla.com/what/is/this/random.gif
http://blabla.com/random.gif


任何建议都将不胜感激。

So I wrote an HttpHandler that does a bunch of processing then writes a gif
to the HttpContext.

What I want to do is have my handler intercept any requests for *random.gif
How might I go about getting this to work? Of course my handler works
perfect on my dev machine....because I added this to the web.config:

<add verb="*" path="*random.gif" type="Assembly.Handler" />

So all the requests for normal images works, and *random.gif gets picked up
by my handler...But as soon as I put it on a test server it didn''t work
(assuming it is because I have to add the ISAPI extention). As a result I
associated the gif extention to the aspnet_isapi, but then it executes on
all images (as I expected but tried anyways).

Hopefully I got my point across. Any suggestions on how to get my handler
to intercept *random.gif.
Paths can be anything from http://blabla.com/what/is/this/random.gif or
http://blabla.com/random.gif

Any suggestions would be appreciated.

推荐答案

你必须在IIS中为你的vdir添加.gif到asp.net的映射图。

下一个主要版本的iis将允许在网络配置中设置。


- 布鲁斯(sqlwork.com)


" preport" < PR ***** @ newsgroups.nospam>在消息中写道

新闻:Ov ************* @ TK2MSFTNGP10.phx.gbl ...
you have to add .gif the to asp.net mapping map in IIS for your vdir. the
next major release of iis will allow this to be set in the web config.

-- bruce (sqlwork.com)

"preport" <pr*****@newsgroups.nospam> wrote in message
news:Ov*************@TK2MSFTNGP10.phx.gbl...
所以我写了一个HttpHandler,然后大量处理将一个
gif写入HttpContext。

我想要做的是让我的处理程序拦截任何请求
* random.gif
我怎么能让这个工作?当然我的处理程序在我的开发机器上运行完美....因为我将它添加到web.config:

< add verb =" *"路径= QUOT * random.gif"类型= QUOT; Assembly.Handler" />

所以对普通图像的所有请求都有效,并且* random.gif被我的处理程序选中了......但是只要我把它放在测试服务器上就可以了没有工作
(假设是因为我必须添加ISAPI扩展)。结果我将gif扩展关联到了aspnet_isapi,但随后它在
所有图像上执行(正如我所料,但无论如何都试过了)。

希望我明白我的观点。关于如何让我的处理程序的任何建议
拦截* random.gif。
路径可以是任何来自 http://blabla.com/what/is/this/random.gif
http://blabla.com/random.gif

任何建议都将不胜感激。
So I wrote an HttpHandler that does a bunch of processing then writes a
gif to the HttpContext.

What I want to do is have my handler intercept any requests for
*random.gif
How might I go about getting this to work? Of course my handler works
perfect on my dev machine....because I added this to the web.config:

<add verb="*" path="*random.gif" type="Assembly.Handler" />

So all the requests for normal images works, and *random.gif gets picked
up by my handler...But as soon as I put it on a test server it didn''t work
(assuming it is because I have to add the ISAPI extention). As a result I
associated the gif extention to the aspnet_isapi, but then it executes on
all images (as I expected but tried anyways).

Hopefully I got my point across. Any suggestions on how to get my handler
to intercept *random.gif.
Paths can be anything from http://blabla.com/what/is/this/random.gif or
http://blabla.com/random.gif

Any suggestions would be appreciated.



这在我的情况下不会起作用.....因为我说它可能是



http://blabla.com/what/is/这/ random.gif http://blabla.com/random.gif


我可以做相反的事情......比如在任何地方注册处理程序除了我的

/ image /文件夹吗?


我可以进入images文件夹并在ISAPI过滤器中执行某些操作?比如

将.gif扩展名添加到某个任意的dll或静态文件处理程序或

的东西(是的......我想我确实做了一半... ..static file

handler ????? haha​​ha)


That''s not going to work in my situation.....because like I said it might be
in

http://blabla.com/what/is/this/random.gif or http://blabla.com/random.gif

Can I do the exact opposite...like register the handler everywhere EXCEPT my
/image/ folder?

Can I go into the images folder and do something in the ISAPI filters? Like
add the .gif extention to some arbitrary dll or static file handler or
something (yes...I think I did make half of that up......static file
handler????? hahaha)



Hi Preport,


感谢您的发布。


关于您的方案,您只需要一些特定的请求

" gif"扩展(xxxrandom.gif)由ASP.NET处理程序处理,

但是其他gif请求仍由IIS处理。基于我的
经验,这样的任务很难直接在ASP.NET级别完成,或者通过IIS扩展来实现
(因为它只支持基本的扩展设置

" .xxx")。我想你可能需要考虑开发一个自定义的IIS isapi

过滤器,如果你想拦截一​​些特定的请求到你的特定处理程序处理的gif文件是

,但仍然是其他人由IIS处理。

以下是IIS isapi过滤器的一些资源:

#ISAPI过滤器概述
http://msdn.microsoft.com/library/en ... c31-41d7-9dc4-

efa83f813521.asp?frame = true

http://www.microsoft.com/msj/0498/iis/iis.aspx

http: //msdn.microsoft.com/library/de...us/vccore98/HT

ML / _core_isapi_extensions.3a_.filters.asp

BTW,如果你认为可以制作所有的gi f文件请求由

ASP.NET运行时处理,你可以考虑使用不同的处理程序处理

不同类型的gif请求(静态文件处理程序和你的自定义

handler)。


希望这会有所帮助。


问候,


Steven Cheng

Microsoft在线支持


安全! www.microsoft.com/security

(此帖子按原样提供,不作任何保证,并且不授予

权利。)

Hi Preport,

Thank you for posting.

Regarding on your scenario, you want only some particular requests for
"gif" extension (xxxrandom.gif) to be processed by your ASP.NET handler,
but let other gif requests still be processed by IIS. Based on my
experience, such task is hard to be done directly at ASP.NET level or
through IIS extension(since it only support a basic extension setting
".xxx"). I think you may need to consider developing a custom IIS isapi
filter if you want to intercept some particular requests to gif file be
handled by your particular handler , but remain others be processed by IIS.
Here are some resource about IIS isapi filter:

#ISAPI Filter Overview
http://msdn.microsoft.com/library/en...c31-41d7-9dc4-
efa83f813521.asp?frame=true

http://www.microsoft.com/msj/0498/iis/iis.aspx

http://msdn.microsoft.com/library/de...us/vccore98/HT
ML/_core_isapi_extensions.3a_.filters.asp
BTW, if you think it ok to make all the gif files requests to be handled by
ASP.NET runtime, you can consider use different handlers to handle
different kind of gif requests( static file handler and your custom
handler).

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


这篇关于HttpHandler问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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