在 ASP.Net 中创建紧凑的非 SOAP Web 服务
我想创建一个简单的 Web 服务来分发给 ASP.Net 开发人员。我找到了一个应用程序(SvnBridge),它具有我想要的布局 - 一个 web.config
文件和单个 .dll
文件。
有趣的部分在 web.config
文件中:
<httpHandlers>
<clear/>
<add verb="*" path="*" type="SvnBridgeServer.SvnBridgeHttpHandler, SvnBridgeServer" />
</httpHandlers>
噢,看起来很完美。我可以在这里抛出任何我喜欢的东西,并由我认为是 IHttpHandler
实现来处理它。
因此,我剥夺了前面链接的配置文件的精髓,将我的库捆绑到一个 DLL 中,并在 VS 中点击构建。我立即在 IE 中得到这个:
来源错误:
[没有相关源代码行]
我主要使用 PHP - ASP.Net 对我来说相当新。显然我做错了什么,但我不知道从哪里开始。
目前,我使用 Python 脚本将所有 C# 源代码捆绑到一个 .ashx
文件中,这对于分发来说有点酷,但使调试成为一场噩梦。它看起来有点像这样:
<%@ WebHandler Language="C#" Class="MyApp.MyClass" debug="true" %>
using System.Data;
...
namespace MyApp
{
public class MyClass : IHttpHandler
{
public void ProcessRequest(HttpContext Http)
{
...
}
}
}
显然还有更多内容(用户配置区域等),但您明白了要点。
有人能指出我正确的方向吗?我对 C# 语言很满意,只是排列和配置让我有点难受。
我意识到这个问题可能看起来有些模棱两可 - 请发表评论,我会在必要时尽力澄清。
谢谢,
尼尔。
I want to create a simple web service to distribute to ASP.Net developers. I found an application (SvnBridge) which has the layout I'm after - a single web.config
file and a single .dll
file.
The interesting part is in the web.config
file:
<httpHandlers>
<clear/>
<add verb="*" path="*" type="SvnBridgeServer.SvnBridgeHttpHandler, SvnBridgeServer" />
</httpHandlers>
Ooooo that looks perfect. I can throw anything I like at this and have it handled by what I presume is an IHttpHandler
implementation.
So I ripped off the spirit of the afore-linked config file, bundled my library into a DLL and hit build in VS. I immediately get this in IE:
Source Error:
[No relevant source lines]
I mainly work with PHP - ASP.Net is quite new to me. Clearly I'm doing something wrong, but I haven't a clue where even to start.
At the moment, I use a Python script to bundle all the C# source into a single .ashx
file, which is kinda cool for distribution, but makes debugging a nightmare. It looks a bit like this:
<%@ WebHandler Language="C#" Class="MyApp.MyClass" debug="true" %>
using System.Data;
...
namespace MyApp
{
public class MyClass : IHttpHandler
{
public void ProcessRequest(HttpContext Http)
{
...
}
}
}
There's obviously a lot more to it (user config area etc), but you get the gist.
Can someone point me in the right direction? I'm comfortable with the C# language, it's just the arrangement and configuration that has me a bit stumped.
I realise this question may seem somewhat ambiguous - please post comments and I'll try to clarify where necessary.
Thanks,
Neil.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事件日志说什么?可能应该有一条记录(类型为“警告”,源看起来像“ASP.NET xxxxxxx.x”)。
不管怎样,您在文章开头提到您希望分发一个 DLL 文件(与 web.config 一起)。稍后您指向
.ashx
文件。我宁愿创建一个类(项目中的 .cs 文件)并将我的 HTTP 处理程序的实现放在该类中。
另外,请仔细检查 web.config 中是否正确指定了 HTTP 处理程序的类型:
如果您使用的是 IIS6,则需要手动添加通配符脚本映射,以便 HTTP 处理程序“捕获”请求。 此论坛帖子可能会有所帮助。
——帕维尔
What does the EventLog say ? There probably should be a record (of type "Warning" with the source which looks like "ASP.NET x.x.xxxxx.x").
Anyway, you mentioned in the beginning of your post that you'd like to have a single DLL-file (among with the web.config) to be distributed. Later you point to the
.ashx
file.I'd rather create a single class (.cs file within your project) and put the implementation of my HTTP handler in that class.
Also, double-check that the type of your HTTP handler is specified correctly in a web.config:
If you're using IIS6 then you need to manually add a wildcard script mapping in order for your HTTP handler to "catch" the requests. This forum post might help.
-- Pavel
这是固定的。我必须将该文件夹转换为 IIS 中的应用程序,并将源移动到受信任的(非网络)位置。
我感谢那些花时间审查这个问题的人。
This is fixed. I had to turn the folder into an application in IIS, and move the source to a trusted (non-network) location.
My gratitude for those who took the time to review this question.