You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Try registering IEmailService with a factory method that injects ViewEngines.Engines explicitly, like this: container.RegisterType(new InjectionFactory(c => new EmailService(ViewEngines.Engines)));. This Solution should ensure that the ViewEngines are passed properly during injection.
I am having trouble with Postal setup. I have registered dependencies like below:
container.RegisterType<IEmailParser, EmailParser>(); container.RegisterType<IEmailViewRenderer, EmailViewRenderer>(); container.RegisterType<IEmailService, EmailService>();
On the controller side I have the following code:
private readonly IEmailService _emailService;
public EmailsController(IEmailService emailService)
{
this._emailService = emailService;
}
public ActionResult Test()
{
var email = new TestEmail
{
}
The dependencies are being injected properly by the unity container but the target view ("Test") is not being found by ViewEngine.
However, when I have the following code in the controller everything works fine.
private readonly IEmailService _emailService = new EmailService(ViewEngines.Engines);;
public ActionResult Test()
{
var email = new TestEmail
{
}
I believe I'm doing something wrong while registering the unity container. Please help me out.
Thanks
The text was updated successfully, but these errors were encountered: