ASP.net 웹 양식을 개발 중이며 웹 사이트에 AutoFac을 구현하고 싶습니다.asp.net 웹 양식에서 autofac 구현
나는 다음 링크의 단계를 따랐다 : https://code.google.com/p/autofac/wiki/WebFormsIntegration
하지만이 오류가 발생했습니다 : 내 프로젝트 Global.asax.cs
만 Global.asax
을 찾을 수 없습니다
This module requires that the HttpApplication (Global Application Class) implements IContainerProviderAccessor.
.
Global.asax
:
<%@ Application Language="C#" %>
<%@ Import Namespace="Autofac" %>
<%@ Import Namespace="Autofac.Integration.Web" %>
<script RunAt="server">
public class Global : HttpApplication, IContainerProviderAccessor {
// Provider that holds the application container.
static IContainerProvider _containerProvider;
// Instance property that will be used by Autofac HttpModules
// to resolve and inject dependencies.
public IContainerProvider ContainerProvider {
get { return _containerProvider; }
}
void Application_Start(object sender, EventArgs e) {
// Code that runs on application startup
// Build up your application container and register your dependencies.
var builder = new ContainerBuilder();
//builder.RegisterType<SomeDependency>();
// ... continue registering dependencies...
// Once you're done registering things, set the container
// provider up with your registrations.
_containerProvider = new ContainerProvider(builder.Build());
}
}
</script>
어떤 아이디어가? 고마워요!
이미 web.config에 추가했습니다. 여전히 같은 오류가 있습니다 ... –