我目前正在使用允许下载PDF格式发票的平台。 为此,我使用了局部视图。当我测试本地一代时,一切正常。当我在我们的服务器(Windows 2016服务器)上预订项目时出现问题
我放置了日志以了解问题的根源,并且出现以下错误:
An unhandled exception has occurred: Cannot return null from an action method with a return type of 'Microsoft.AspNetCore.Mvc.IActionResult'
当我移至下一项时,似乎会发生此错误:
var viewContext = new ViewContext(actionContext,viewResult.View,viewDictionary,new TempDataDictionary(actionContext.HttpContext, _tempDataProvider),sw,new HtmlHelperOptions());
下面是viewContext变量中存在的元素的不同初始化
var httpContext = new DefaultHttpContext { RequestServices = _serviceProvider };
var actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());
var sw = new StringWriter();
var viewResult = _razorViewEngine.FindView(actionContext, "MyAccount/InvoiceTemplate", false);
var viewDictionary = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()){Model = viewModel};
_tempDataProvider在控制器的开头初始化。
预先感谢您的回答。