Guys, Global.asax 메서드 내에서 asp.net mvc 2 응용 프로그램의 실제 경로를 가져올 수 있습니까?global.asax의 응용 프로그램에 대한 실제 경로
UPD : 죄송 합니다만, Ninject IoC 컨테이너 구성에서 해당 경로를 가져와야한다는 것을 잊지 마십시오. 당신은 HttpRuntime.AppDomainAppPath
property 찾고있는
public class MvcApplication : System.Web.HttpApplication
{
...
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
ControllerBuilder.Current.SetControllerFactory(typeof(IOCControllerFactory));
}
}
public class IOCControllerFactory : DefaultControllerFactory
{
private readonly IKernel kernel;
public IOCControllerFactory()
{
kernel = new StandardKernel(new NanocrmContainer());
}
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
var controller = kernel.TryGet(controllerType) as IController;
if (controller == null)
return base.GetControllerInstance(requestContext, controllerType);
var standartController = controller as Controller;
return standartController;
}
class NanocrmContainer : Ninject.Modules.NinjectModule
{
public override void Load()
{
Bind<IFileService>().To<BusinessLogic.Services.FileService>().InRequestScope().WithConstructorArgument("temp", "Temp").WithConstructorArgument("docs", "Documents"); // Temp and Documents should be replaced with corresponding paths
}
}
}
업데이트의 차이점은 무엇입니까? – SLaks
@SLaks : 아무 것도. 나는 부주의했습니다. ;-) – zerkms