我正在尝试使用以下代码将文件上传到MVC 6应用程序。
public void UploadFile(IEnumerable<IFormFile> files)
{
foreach (var file in files)
{
var parsedContentDisposition = ContentDispositionHeaderValue.Parse(file.ContentDisposition);
using (var reader = new StreamReader(file.OpenReadStream()))
{
var fileContent = reader.ReadToEnd();
var Filename = parsedContentDisposition.FileName;
}
}
}
我遇到了以下错误,请帮忙解决一下。我不确定该怎么办,我已经尝试使用最新版本的Microsoft.AspNet.StaticFiles,但问题仍然存在。
System.TypeLoadException
Method 'get_WebRootFileSystem' in type 'Microsoft.AspNet.Hosting.HostingEnvironment' from assembly 'Microsoft.AspNet.Hosting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
at Microsoft.Framework.DependencyInjection.HostingServicesExtensions.AddHosting(IServiceCollection services, IConfiguration configuration)
at Microsoft.AspNet.Hosting.HostingServices.Create(IServiceProvider fallbackServices, IConfiguration configuration)
at Microsoft.AspNet.Loader.IIS.KlrHttpApplication.ApplicationStart(IHttpApplication application)
at Microsoft.AspNet.Loader.IIS.HttpApplicationBase.InvokeApplicationStart(IHttpApplication application)