Physical path to global.asax

Guys, is it possible to get the physical path to an asp.net mvc 2 application inside Global.asax methods?

UPD : sorry, I forgot to say that I need to get this path in the configuration of the Ninject IoC container.
This is a sketch of what I have now:

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 } } } 
+4
source share
1 answer

You are looking for the HttpRuntime.AppDomainAppPath property.

+11
source

Source: https://habr.com/ru/post/1310696/


All Articles