캐슬/윈저에 새로운 있습니다. 나와 함께하시기 바랍니다.성 PerRequestLifestyle을 인식 할 수 없음
나는 현재 프레임 워크 System.Web.Mvc.Extensibility를 사용하고 그 시작 코드, 그것은 다음과 같이 HttpContextBase 등록 : 내가하고 싶었던 무엇
container.Register(Component.For<HttpContextBase>().LifeStyle.Transient.UsingFactoryMethod(() => new HttpContextWrapper(HttpContext.Current)));
가 될 httpContextBase의 라이프 스타일을 동작을 변경하고 변경하는 것입니다 PerWebRequest. 그러나,
System.Configuration.ConfigurationErrorsException: Looks like you forgot to
register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule
Add '<add name="PerRequestLifestyle"
type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.MicroKernel"
/>' to the <httpModules> section on your web.config
내가 <system.web>
및 <system.webServer>
에서 한 :
container.Register(Component.For<HttpContextBase>().LifeStyle.PerWebRequest.UsingFactoryMethod(() => new HttpContextWrapper(HttpContext.Current)));
을 그러나, 나는이 작업을 수행 할 때, 나는 다음과 같은 오류가 발생했습니다 :
그래서 나는 다음에 코드를 변경해야 , 나는 여전히 같은 오류가 발생하고 있습니다. 어떤 힌트?
미리 감사드립니다.
업데이트이
system.web.mvc.extensibility 프레임 워크에서
요청
당 코드 블록이이 같이 HttpApplication에서 상속 extendedMvcApplication라는 클래스이며, 위해 Application_Start 방법 추가, 그것은 호출 BootStrapper.Execute(). 당신이 볼 수 있듯이, 그것은 IBootStrapperTask의 목록을 반복하고이를 실행하려고public void Execute()
{
bool shouldSkip = false;
foreach (IBootstrapperTask task in ServiceLocator.GetAllInstances<IBootstrapperTask>().OrderBy(task => task.Order))
{
if (shouldSkip)
{
shouldSkip = false;
continue;
}
TaskContinuation continuation = task.Execute(ServiceLocator);
if (continuation == TaskContinuation.Break)
{
break;
}
shouldSkip = continuation == TaskContinuation.Skip;
}
}
:이 방법이 구현은 다음과 같다. 내가 내 MVC 응용 프로그램의 경로를 등록 할 하나의 작업을 가지고 발생합니다
public class RegisterRoutes : RegisterRoutesBase
{
private HttpContextBase contextBase;
protected override TaskContinuation ExecuteCore(IServiceLocator serviceLocator)
{
contextBase = serviceLocator.GetInstance<HttpContextBase>();
return base.ExecuteCore(serviceLocator);
}
protected override void Register(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
routes.IgnoreRoute("{*robotstxt}", new { robotstxt = @"(.*/)?robots.txt(/.*)?" });
XmlRouting.SetAppRoutes(routes, contextBase.Server.MapPath("~/Configuration/Routes.xml"));
}
}
당신은 내가의 getInstance (해결) 나는 XML 파일의 서버 경로를 얻을 수있는 것과 같은 httpcontextbase 객체에 필요한 것을 알 수 있습니다 .
언제 해당 개체를 해결합니까? 어느 시점에서? Application_Start()의 –
은 너무 일찍 끝났습니까? – Herman
@Herman : 현재 지원되지 않습니다. Application_Start()에서 무엇을 해결하려고합니까? –