asp.net에서 autofac을 사용하고 있습니다. 그런 다음asp.net with autofac - webform의 모든 컨트롤이 null입니다.
AssertNotBuilt();
// Register Web Pages
m_builder.RegisterAssemblyTypes(typeof(AboutPage).Assembly)
.Where(t => t.GetInterfaces().Contains(typeof(IHttpHandler)))
.AsSelf().InstancePerLifetimeScope();
m_container = m_builder.Build();
m_wasBuilt = true;
나는 현재 웹 페이지 얻을 수있는 사용자 지정 HttpHandler를를 사용하십시오 :
public class ContextInitializerHttpHandler : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
//Get the name of the page requested
string aspxPage = context.Request.Url.AbsolutePath;
if (aspxPage.Contains(".aspx"))
{
// Get compiled type by path
Type webPageBaseType = BuildManager.GetCompiledType(aspxPage).BaseType;
// Resolve the current page
Page page = (Page)scope.Resolve(webPageBaseType);
//process request
page.ProcessRequest(context);
}
}
public bool IsReusable
{
get { return true; }
}
}
모든 작품을 좋아,하지만 그때는 웹를 Page_Load에 들어갈 때의 Global.asax에 내 모든 웹 페이지를 등록 , 페이지에 존재하는 모든 ASP 컨트롤이 null 인 것을 볼 수 있습니다. 왜 그들은 null이고 어떻게 초기화합니까?
당신은 여기에 몇 가지를 명확히해야 할 수도 있습니다
그래서 솔루션 (또는 해킹 ..) 웹 페이지를 등록하고 대신 범위에서 페이지 컨트롤을 해결하기 위해 아니었다. 아주 비표준적인 일을하는 것처럼 보입니다. Autofac 위키는 웹 양식 (https://code.google.com/p/autofac/wiki/AspNetIntegration)과의 통합 방법을 알려줍니다. Autofac이 제공하는 MODULE 통합이 아닌 HANDLER를 사용하는 것 같습니다. 사용자가 귀하의 페이지에 어떻게 액세스합니까? 모든 요청은 해당 처리기를 통해 파이프됩니까? 문제를 해결하기보다 페이지를 "새로 만들면"어떻게됩니까? 여전히 null입니까? –