【发布时间】:2011-10-20 07:47:22
【问题描述】:
我想在我的 xml 配置中启用 scope="request" 属性:
<object id="IDataAccess" type="Dal.DataAccess, Dal" scope="request">
我的 WCF 服务托管在 IIS 上,我使用 RouteTable 和 ServiceHostFactory 创建我的服务:
static void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.Add(new ServiceRoute("url", serviceHostFactory, typeof(MyService)));
}
我在web.config 中添加了WebContextHandler 以启用request 和session 的范围,如此处所述http://www.springframework.net/doc-latest/reference/html/web.htm(第22.3.1 节)
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
</sectionGroup>
还有httpModules的东西:
<system.web>
<httpHandlers>
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
</httpHandlers>
<httpModules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</httpModules>
</system.web>
而且因为我在window 7,framework Net 4.0我也加了:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</modules>
</system.webServer>
我做到了。它不起作用,我还有:
Resource handler for the 'web' protocol is not defined.
当它调用时:
SpringContext = (IApplicationContext)ConfigurationManager.GetSection("spring/context");
我现在不知道该怎么做,Spring.net 社区的人可以帮助我吗?看起来我并没有尝试做一些棘手或骇人的事情。在 IIS 中托管 WCF 服务是一种常见模式。
编辑:
我试过了
<add verb="*" path="*" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
按照 cmets 的建议,它不起作用。
【问题讨论】:
-
您似乎只为 *.aspx 资源添加了处理程序。
-
好吧,我必须说我真的不知道我做了什么,到底什么是处理程序?我只是从 Spring 配置中复制这些行。如何为所有资源启用处理程序?通过设置路径 =“*”。我试试看
-
Spring.Web.Support.PageHandlerFactory是Spring.Web.Pages 的工厂,所以我认为您不能将它用于您的 wcf 端点。恐怕现阶段我对 wcf 了解的太少,无法进一步提供帮助,抱歉。
标签: c# wcf iis spring.net