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

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

问题描述

我们在我们的web.config文件中指定的HTTP处理程序。当我们通过运行一个网站项目这个网站,一切工作正常。但由于某些原因,这在移植到WAP项目,并指向.NET 3.5框架后,处理程序不会当我把在IIS 7的网站上我们开发框工作。我需要做IIS7比指定自定义处理程序等一些特别的东西已经在我的web.config存在?

当我看到我们的网站在IIS 7中的处理程序映射部分中,我看到我们的自定义扩展中列出的3处理器。因此,它看起来像它的拿起我们的web.config中指定我们的处理程序。但我知道,那是在一个非WAP网站工作处理程序不在此WAP项目的工作,我不知道为什么。

例如,当我们的处理程序之一试图踢在引用时我得到:

在'/'应用程序的服务器错误。
分析器错误
说明:该请求提供服务所需资源的分析过程中出现错误。请检查下列特定分析错误详细信息并适当地修改源文件。

分析器错误信息:无法创建类型jaxHandler。源错误:1号线:
2号线:
3号线:​​使用系统;
源文件:/jaxHandler.ashx线:1版本信息:Microsoft .NET Framework版本:2.0.50727.3074; ASP.NET版本:2.0.50727.3074

此外,当我尝试点击我们网站上的一个超链接上有.customextension处理程序似乎并没有把它捡起来。

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

HTTP错误404.0 - 未找到
您正在寻找已被删除的资源,更名或暂时不可用。详细错误InformationModule IIS Web核心
通知马prequestHandler
处理程序StaticFile
错误code 0x80070002
请求的URL的http:// SSS:80 / somename.prod
物理路径C:\\ WWW \\ SSS \\ somename.prod
登录方法匿名
登录用户匿名

(我已取代somename我们公司以SSS名实文本)以上的隐私的情况。

如果我期待在IIS7的HTTP处理程序段,我看到* .prod注册。这里是我们如何在我们的web.config下设自定义栏目:

 <添加名称=SSS路径=*刺。动词=*的模块=IsapiModulescriptProcessor ​​=C:\\ WINDOWS \\ Microsoft.NET \\框架\\ V2.0.50727 \\ ASPNET_ISAPI.DLL= resourceType为未指定preCondition =bitness32/>


解决方案

您需要做的是建立自己的code。

您需要拷出所有的C#code到.ashx.cs文件。事实上,我建议你创建一个新的ashx的和C#code复制到其.ashx.cs文件。

网站动态构建。 Web应用程序项目,就像在Visual Studio中的每个其他类似的项目类型,需要在源文件code,并有code打造成为集。

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?

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 

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:\www\sss\somename.prod 
Logon Method Anonymous 
Logon User Anonymous 

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

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:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="bitness32"/>

解决方案

What you need to do is build your code.

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 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天全站免登陆