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()'?單元測試還是來自瀏覽器? –
@湯姆·雷德芬是我用這個 –