Asp.net 路由、Web 服务和 IIS7 经典

发布于 2024-07-20 06:25:12 字数 2171 浏览 10 评论 0原文

我有一个在 IIS7 Classic 上运行的 Web 表单应用程序。 它利用 .asmx 风格的 Web 服务来处理网站的客户端部分。

我们的任务是在“友好的 url”中进行分层,并决定使用新的 Asp.net 路由。 我们在 IIS 中有一条规则,将所有请求映射到 aspnet_isapi.dll,这会在我们的 web.config (system.webServer/hanlers) 中生成此声明:

<add name="asp.net routing" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness32" />

但是现在路由中断了我们的 .asmx webservice 请求(形式为 http://example.com/blah.asmx/SomeMethod)。 对 Web 服务的任何请求都给我们带来了永远的乐趣:

Failed to Execute URL.
[HttpException (0x80004005): Failed to Execute URL.]
System.Web.Hosting.ISAPIWorkerRequestInProcForIIS6.BeginExecuteUrl(String url, String method, String childHeaders, Boolean sendHeaders, Boolean addUserIndo, IntPtr token, String name, String authType, Byte[] entity, AsyncCallback cb, Object state) +2004885
System.Web.HttpResponse.BeginExecuteUrlForEntireResponse(String pathOverride, NameValueCollection requestHeaders, AsyncCallback cb, Object state) +393
System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) +223
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8677954
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +155

将这一行放入我们的路由设置中:

routes.Add(new Route("{service}.asmx/{*pathInfo}", new StopRoutingHandler()));

仍然给我们留下“无法执行 URL”异常。 我知道路由是匹配的,因为:

public sealed class DieHandler : IRouteHandler
{
    #region IRouteHandler Members

    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        throw new NotImplementedException();
    }

    #endregion
}
routes.Add(new Route("{service}.asmx/{*pathInfo}", new DieHandler()));

有了该路由,而不是“无法执行 URL”,我看到“方法未实现”,就像我所期望的那样。

我怀疑我们的 * -> aspnet_isapi.dll 正在造成严重破坏,因为我在搜索谷歌时没有发现其他人这样做。

感谢您提前提供任何见解。

I have a web forms app running on IIS7 Classic. It utilizes .asmx style web services for a client side heavy portion of the site.

We have been tasked with layering in "friendly urls" and decided to use the new Asp.net routing. We have a rule in IIS to map all requests to the aspnet_isapi.dll, which yields this declaration in our web.config (system.webServer/hanlers):

<add name="asp.net routing" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness32" />

But now routing breaks our .asmx webservice requests (of the form http://example.com/blah.asmx/SomeMethod). Any request to a web service leaves us with the always fun:

Failed to Execute URL.
[HttpException (0x80004005): Failed to Execute URL.]
System.Web.Hosting.ISAPIWorkerRequestInProcForIIS6.BeginExecuteUrl(String url, String method, String childHeaders, Boolean sendHeaders, Boolean addUserIndo, IntPtr token, String name, String authType, Byte[] entity, AsyncCallback cb, Object state) +2004885
System.Web.HttpResponse.BeginExecuteUrlForEntireResponse(String pathOverride, NameValueCollection requestHeaders, AsyncCallback cb, Object state) +393
System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) +223
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8677954
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Putting this line in our routes setup:

routes.Add(new Route("{service}.asmx/{*pathInfo}", new StopRoutingHandler()));

still leaves us with the "Failed to execute URL" exception. I know the route is matching because of this:

public sealed class DieHandler : IRouteHandler
{
    #region IRouteHandler Members

    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        throw new NotImplementedException();
    }

    #endregion
}
routes.Add(new Route("{service}.asmx/{*pathInfo}", new DieHandler()));

With that route in place instead of "Failed to Execute URL" I see "Method not implemented" like I would expect.

My suspicion is that our * -> aspnet_isapi.dll is wreaking havoc, since I haven't found anyone else doing this while scouring google.

Thanks for any insights in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

累赘 2024-07-27 06:25:12

您需要将 requireAccess="None" 添加到 web.config 中的处理程序中,即:

<add name="aspnet_isapi 32-bit" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv2.0,bitness32" />

这允许正确处理文件

You need to add requireAccess="None" to the handler in web.config, ie:

<add name="aspnet_isapi 32-bit" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv2.0,bitness32" />

This allows the files to be processed correctly

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文