New to Castle/Windsor, please bear with me.
I am currently using the framework System.Web.Mvc.Extensibility and in its start up code, it registered HttpContextBase l
Maby try to add it under Modules section, like here: IIS7 & Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule registering problems
http://www.jasonlinham.co.uk/2009/02/castle-and-iis7.html
As of this writing, PerWebRequest lifestyle does not support resolving in Application_Start().
See issue description and discussion:
Workarounds for this particular case:
Register RegisterRoutes
as an instance, explicitly passing it the current context as constructor parameter, e.g.:
container.Register(Component.For<IBootstrapperTask>()
.Instance(new RegisterRoutes(Context)));
Use HostingEnvironment.MapPath
instead of contextBase.Server.MapPath
. Want to make it mockable? Use it through a simple interface, e.g.:
interface IServerMapPath {
string MapPath(string virtualPath);
}
class ServerMapPath: IServerMapPath {
public string MapPath(string virtualPath) {
return HostingEnvironment.MapPath(virtualPath);
}
}
container.AddComponent<IServerMapPath, ServerMapPath>();
Then inject IServerMapPath
into your RegisterRoutes
.