Asp.net路由,Web服务和IIS7 Classic

时间:2021-01-07 01:58:39

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.

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

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):

我们的任务是在“友好网址”中进行分层,并决定使用新的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" />

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:

但现在路由中断了我们的.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

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:

仍然留给我们“失败的执行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()));

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

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

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

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

Thanks for any insights in advance.

感谢您提前获得任何见解。

2 个解决方案

#1


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

您需要将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" />

This allows the files to be processed correctly

这样可以正确处理文件

#2


You want to add a rule to ignore certain routes. See: Asp.Net Routing: How do I ignore multiple wildcard routes? or http://haacked.com/archive/2008/07/14/make-routing-ignore-requests-for-a-file-extension.aspx

您想要添加规则以忽略某些路由。请参阅:Asp.Net路由:如何忽略多个通配符路由?或http://haacked.com/archive/2008/07/14/make-routing-ignore-requests-for-a-file-extension.aspx

#1


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

您需要将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" />

This allows the files to be processed correctly

这样可以正确处理文件

#2


You want to add a rule to ignore certain routes. See: Asp.Net Routing: How do I ignore multiple wildcard routes? or http://haacked.com/archive/2008/07/14/make-routing-ignore-requests-for-a-file-extension.aspx

您想要添加规则以忽略某些路由。请参阅:Asp.Net路由:如何忽略多个通配符路由?或http://haacked.com/archive/2008/07/14/make-routing-ignore-requests-for-a-file-extension.aspx