Hi All,
I am new in AutoFac and I am stuck with an urgent issue. It would be great if any person can help me out. I would like to inject a method in IHttpModule in a WebApi application. I have tried with various option without luck.Herewith the code snippet,
public class BasicAuthHttpModule : IHttpModule
{
public static Func<IUserBusinessLogic> _userBusinessLogic ;
public BasicAuthHttpModule(Func<IUserBusinessLogic> repository)
{
_userBusinessLogic = repository;
}
private static bool AuthenticateUser(string username,string password)
{
var userObj = _userBusinessLogic().AuthenticateUser(username, password);
//more
}
//more
}
I tried to register the method using
builder.RegisterType<UserBusinessLogic>().As<IUserBusinessLogic>();
I have also gone through the following link
http://www.sapiensworks.com/blog/post/2013/03/18/Http-Module-Dependecy-Injection-with-Autofac-Gotcha.aspx and
http://www.paraesthesia.com/archive/2011/02/08/dynamic-httpmodule-registration-in-asp-net-4-0.aspx/ but not able to succeed.
please help.
Regards,
Ujjwal