![](/img/trans.png)
[英]Why am I getting an exception raised from Spring.NET on the call to ContextRegistry.GetContext()?
[英]Can't get WebApplicationContext object from ContextRegistry.GetContext(): Resource handler for the 'web' protocol is not defined
我被困在一個Web窗體項目下配置我的web.config文件,以便獲取WebApplicationContext實例(位於Global.asax),然后能夠使用scope =“ application | session | request”
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
<spring>
<context type="Spring.Context.Support.WebApplicationContext, Spring.Web">
<resource uri="~/Configuration/Spring.xml" />
</context>
</spring>
<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>
然后,我試圖將WebApplicationContext添加到我的Application對象中,以便在任何.aspx頁上使用;
protected void Application_Start(object sender, EventArgs e)
{
//Exception happens on next line!
Application.Add("ContainerID", ContextRegistry.GetContext());
}
我得到的例外是;
"Error creating context 'spring.root': Resource handler for the 'web' protocol is not defined. Spring.NET"
我花了一些時間進行谷歌搜索,但沒有成功。 Ive在Spring.NET文檔中找到; “在Web應用程序中,Spring提供了一個WebApplicationContext實現,該實現是通過在Web.config文件中添加自定義HTTP模塊和HTTP處理程序來配置的。有關更多詳細信息,請參見Web配置部分。” 但這絕不會發生。
拜托,有人可以幫我嗎?
spring.net容器未在Application_Start
初始化。
順便說一句,為什么要在Application
bucker中添加容器? 這聽起來像是我的反模式...
將此添加到system.webServer配置節點:
<modules runAllManagedModulesForAllRequests="true">
<add name="Spring" preCondition="integratedMode" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</modules>
如果您在IIS7中使用IntegratedMode
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.