0
我正在使用hangfire和使用autofac的DI。我想与postal.mvc5工具发送电子邮件,我得到这个错误:用邮政在hangfire发送邮件
System.InvalidOperationException
The request lifetime scope cannot be created because the HttpContext is not available.
System.InvalidOperationException: The request lifetime scope cannot be created because the HttpContext is not available.
at Autofac.Integration.Mvc.RequestLifetimeScopeProvider.GetLifetimeScope(Action`1 configurationAction)
at Autofac.Integration.Mvc.AutofacDependencyResolver.get_RequestLifetimeScope()
at Autofac.Integration.Mvc.AutofacDependencyResolver.GetService(Type serviceType)
at System.Web.Mvc.BuildManagerViewEngine.DefaultViewPageActivator.Create(ControllerContext controllerContext, Type type)
at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
at Postal.EmailViewRenderer.RenderView(IView view, ViewDataDictionary viewData, ControllerContext controllerContext, ImageEmbedder imageEmbedder)
at Postal.EmailViewRenderer.Render(Email email, String viewName)
at Postal.EmailService.Send(Email email)
at Postal.Email.Send()
at Store.Web.Controllers.HomeController.Test() in C:\Users\a\Documents\Visual Studio 2015\Projects\In\S.Web\Controllers\HomeController.cs:line 33
我寻找2天,并没有发现这个问题。请帮帮我!由于
是否使用了Autofac.Mvc5包? –
你从哪里调用'HomeController.Test()'?单元测试还是来自浏览器? –
@汤姆·雷德芬是我用这个 –