自定义 Http 处理程序 IIS7 和 ASP.NET [英] Custom Http Handlers IIS7 and ASP.NET

查看:18
本文介绍了自定义 Http 处理程序 IIS7 和 ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在 web.config 中指定了一些 HTTP 处理程序.当我们通过网站项目运行该站点时,一切正常.但由于某种原因,在将其移植到 WAP 项目并指向 .NET 3.5 框架后,当我在我们的开发盒上以 IIS 7 启动该站点时,处理程序无法正常工作.除了我的 web.config 中已经存在的指定自定义处理程序之外,我是否需要在 IIS7 中做一些特殊的事情?

We have some HTTP handlers specified in our web.config. When we were running this site via a Web Site Project, all worked fine. But for some reason, after porting this over to a WAP project and pointing to the .NET 3.5 framework, the handlers are not working when I bring up the site in IIS 7 on our dev box. Do I need to do something special in IIS7 other than the specified custom handlers that already exist in my web.config?

当我查看我们网站的 IIS 7 中的处理程序映射部分时,我确实看到了与我们的自定义扩展一起列出的 3 个处理程序.所以看起来它正在获取我们在 web.config 中指定的处理程序.但是我知道在非 wap 网站中工作的处理程序在这个 WAP 项目中不工作,我不知道为什么.

When I look at the Handler Mappings section in IIS 7 for our site, I do see the 3 handlers listed with our custom extension. So it looks like it's picking up our handlers specified in our web.config. But I know that the handlers that were working in a non-wap website are not working in this WAP project and I don't know why.

例如,当我们的一个处理程序在被引用时尝试启动时,我得到:

For example, when one of our handlers tries to kick in when referenced I get:

/"应用程序中的服务器错误.解析器错误说明:解析服务此请求所需的资源时出错.请查看以下特定的解析错误详细信息并适当地修改您的源文件.

Server Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not create type 'jaxHandler'.

Source Error:

Line 1:  
Line 2:  
Line 3:  using System;


Source File: /jaxHandler.ashx    Line: 1

Version Information: Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074 

此外,当我尝试点击我们网站上带有 .customextension 的超链接时,处理程序似乎无法识别它.

furthermore, when I try to click on a hyperlink on our site that has .customextension on it the handler doesn't seem to pick it up.

所以当我点击超链接时,我得到:

So when I click on the hyperlink, I get:

HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Detailed Error InformationModule IIS Web Core 
Notification MapRequestHandler 
Handler StaticFile 
Error Code 0x80070002 
Requested URL http://sss:80/somename.prod
Physical Path C:wwwssssomename.prod 
Logon Method Anonymous 
Logon User Anonymous 

(出于隐私考虑,我已将真实文本替换为somename",将我们的公司名称替换​​为sss").

(I have replaced the real text with 'somename' and our company name with 'sss') in the case above for privacy.

如果我查看 IIS7 中的 Http Handlers 部分,我确实看到 *.prod 已注册.以下是我们在 web.config 中自定义部分下的设置方式:

If I look in the Http Handlers section in IIS7, I do see that *.prod is registered. And here is how we have it set up in our web.config under the custom section:

<add name="sss" path="*.prod" verb="*" modules="IsapiModule" scriptProcessor="C:WindowsMicrosoft.NETFrameworkv2.0.50727aspnet_isapi.dll" resourceType="Unspecified" preCondition="bitness32"/>

推荐答案

你需要做的是构建你的代码.

What you need to do is build your code.

您需要将所有 C# 代码复制到 .ashx.cs 文件中.事实上,我建议你创建一个新的 .ashx 并将 C# 代码复制到它的 .ashx.cs 文件中.

You need to copy all the C# code out into a .ashx.cs file. In fact, I recommend you create a new .ashx and copy the C# code into its .ashx.cs file.

网站是动态构建的.Web 应用程序项目与 Visual Studio 中的所有其他类似项目类型一样,需要在源文件中包含代码,并将该代码构建到程序集中.

Web sites build dynamically. Web Application Projects, like every other similar project type in Visual Studio, need to have code in source files, and to have that code build into an assembly.

这篇关于自定义 Http 处理程序 IIS7 和 ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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