如何创建一个HTTP处理所有流量重定向到HTML页面? [英] How can I create an http handler to redirect all traffic to HTML pages?

查看:174
本文介绍了如何创建一个HTTP处理所有流量重定向到HTML页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的公司想重定向所有来电到我们的服务器上的文件的HTML一个单独的页面。
HTML页面是不是在asp.net应用程序。

Our company would like to redirect all calls to html files on our server to a separate page. The html pages are NOT in an asp.net application.

在为了做到这一点,我已经在asp.net写,IIS处理程序。

In order to do this, I've been writing and IIS Handler in asp.net.

1)这是有可能增加一个IIS处理重定向不是由任何asp.net发动机供应的静态内容,即,在服务器上独立的文件?

1) Is this possible to add an IIS handler to redirect static content that isn't served by any asp.net engine, i.e. stand alone files on the server?

2)如果可能的话,我该怎么办呢?我创建了一个类库HTTP处理程序。在App.config我添加了处理程序到和章节。我加了DLL到GAC,我改变了HTML映射到我的自定义IIS DLL并没有什么作品。是否有从A教程或解释到B就如何做到这一点?

2) If it is possible, how do I do this? I created an http handler in a class library. In the app.config I added the handler to the and sections. I added the DLL to the GAC, I changed the html mapping to my custom IIS dll and nothing works. Is there a tutorial or explanation from A to B on how to do this?

感谢。

电子

P.S。我使用的是IIS 7.5

p.s. I'm using IIS 7.5

推荐答案

在默认情况下,IIS将处理与延期请求。这意味着你的自定义HTTP处理程序不被调用。如果你想管理code来处理所有的请求,那么你就需要设置这个配置在Web.config中:

By default, IIS will handle requests with extensions. This means your custom HTTP handler isn't being called. If you want managed code to handle all requests then you'll need to set this configuration in Web.config:

<模块runAllManagedModulesForAllRequests =真/>

然后,它注册在Web.config中的HTTP处理程序,确保它的第一个处理程序来接收所有请求一件简单的事情。

Then, it's a simple matter of registering your HTTP handler in Web.config, making sure it's the first handler to receive all requests.

此外,您可能要检查到IIS URL重写,因为它可能是一个更好的性能解决了这个问题。

Also, you may want to check into IIS URL rewriting as it may be a better-performance solution to this problem.

这篇关于如何创建一个HTTP处理所有流量重定向到HTML页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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