简体   繁体   English

如何将处理程序映射设置为IIS 6.0中的目录?

[英]How do you set handler mapping to a directory in IIS 6.0?

I have IIS 7.0 on my development machine and IIS 6.0 on my server. 我的开发机上有IIS 7.0,服务器上有IIS 6.0。 On my development machine I was able to set a handler map on a directory within my site called /ViewHtml/ and I mapped it to asp.net. 在开发机器上,我可以在我的站点中名为/ ViewHtml /的目录中设置处理程序映射,然后将其映射到asp.net。 In my global.asax I check the request sent to asp.net for /ViewHtml/ and I serve the appropriate html file(html version of a Doc, Power Point, or Excel file) located outside this apps virtual directory. 在我的global.asax中,我检查发送到asp.net的/ ViewHtml /的请求,并提供位于此应用程序虚拟目录之外的相应html文件(Doc,Power Point或Excel文件的html版本)。 I am doing it this way because all files are permission protected, we didn't want to put these files in are database due to scalability, and I need to hide the path to these file on the server. 我这样做是因为所有文件都受权限保护,由于可伸缩性,我们不想将这些文件放在数据库中,并且我需要在服务器上隐藏这些文件的路径。 This all works in IIS 7.0 exactly how I would like it to. 所有这些都完全可以在IIS 7.0中正常运行。 Although I have not been able to get my IIS 6.0 server configured to map all requests to that directory to asp.net. 尽管我无法将IIS 6.0服务器配置为将所有请求映射到该目录到asp.net。

Any ideas? 有任何想法吗? Thanks Guys? 多谢你们?

If I understand the problem correctly, it sounds like you need add a "Wildcard Application Mapping" for your virtual directory. 如果我正确理解了问题,听起来您需要为虚拟目录添加“通配符应用程序映射”。 In other words, you want to forward all requests to any file extension to ASP.NET's ISAPI extension. 换句话说,您想将所有请求转发到ASP.NET的ISAPI扩展名的任何文件扩展名。

To do so, open the properties of your virtual directory. 这样做,打开您的虚拟目录的属性。 On the Virtual Directory tab (Home Directory tab if it's a web site), click the Configuration... button. 在“ 虚拟目录”选项卡(如果是网站,则为“主目录”选项卡)上,单击“ 配置...”按钮。 Click the Insert... button next to the bottom list box in the dialog that shows up. 在出现的对话框中,单击底部列表框旁边的“ 插入...”按钮。 In this dialog, choose "%SYSTEMROOT%\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet_isapi.dll" as the executable and make sure to un-check "Verify that file exists" checkbox, since the files to be requested don't live in your virtual directory. 在此对话框中,选择“%SYSTEMROOT%\\ Microsoft.NET \\ Framework \\ v2.0.50727 \\ aspnet_isapi.dll”作为可执行文件,并确保取消选中“验证该文件是否存在”复选框,因为要请求的文件没有不在您的虚拟目录中。

I hope this helps! 我希望这有帮助!

I set up a web application using the same configuration you're using and I'm also getting the 404. I don't know why it works in IIS 7, but here's what I had to do to fix it. 我使用与您使用的配置相同的配置设置了一个Web应用程序,并且也得到了404。我不知道为什么它在IIS 7中可以正常工作,但是这是我必须修复的工作。

Create a class that implements the System.Web.IHttpHandler class. 创建一个实现System.Web.IHttpHandler类的类。 move the the code from Application_BeginRequest to your implementation of IHttpHandler.ProcessRequest. 将代码从Application_BeginRequest移到IHttpHandler.ProcessRequest的实现中。

Now you just have to register your HTTP handler with ASP.NET. 现在,您只需要在ASP.NET中注册HTTP处理程序即可。 To do so add an entry in your Web.config at /configuration/system.web/httphandlers. 为此,请在Web.config中的/configuration/system.web/httphandlers中添加一个条目。

Web.config Example: Web.config示例:

...
<httpHandlers>
    <clear />
    <add verb="*" path="*" type="namespace.classname, assemblyname" />
</httpHandlers>
...

That entry is telling ASP.NET to handle HTTP requests with any extension and any HTTP method by running the code in your HTTP hander. 该条目告诉ASP.NET通过运行HTTP处理程序中的代码来处理具有任何扩展名和任何HTTP方法的HTTP请求。 Note that I'm also clearing all the previously definded handlers (defined in the machine's web.config). 请注意,我还清除了所有先前定义的处理程序(在计算机的web.config中定义)。

Note that you will still need the Application Mapping configured in IIS. 请注意,您仍然需要在IIS中配置应用程序映射。

我认为您的问题全与访问策略有关,您必须确保访问策略为“读取”而不是“无”,与“无”的cz,您甚至没有权限从您的网站读取文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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