System.Web.UI.Request
不.NET核心提供這樣的一個問題是關於這個命名空間的替代品。System.Web.UI.Request不是.NET提供的核心,需要替代
我需要讀取服務器上傳的文件內容。在.net的4.5版本中,我的工作方式與HttpPostedFile file = Request.Files["content"];
類似,但現在這不適用於.net內核。我需要知道在.net核心文件上傳的最佳示例是否有其他選擇,請分享。
以下是我的舊代碼。
HttpPostedFile file = Request.Files["content"];
byte[] fileData = null;
using (var binaryReader = new BinaryReader(file.InputStream))
{
fileData = binaryReader.ReadBytes(file.ContentLength);
}
var fileName = Request.Form["fileName"];
FileBusiness.SaveFile(domain, new Guid(token), fileName, fileData, true);
Response.Write("Normal file uploaded");
我要求在RC1是在心裏想着上傳文件功能在RC1可用,但我在.NET 1.0的核心庫RTM已經找到。我需要知道是否有任何方式上傳.net核心RC1中的文件?
你使用什麼中間件?從文檔中可以看出:ASP.NET Core有許多體系結構上的改變,這些改變導致了一個更精簡和模塊化的框架。 ASP.NET Core不再基於System.Web.dll。它基於一組精細且充分考慮的NuGet包。這使您可以優化您的應用程序,只包含您需要的NuGet包。 https://docs.asp.net/en/latest/intro.html –
[如何獲取ASP.NET核心中的HttpContext.Current?](http://stackoverflow.com/questions/38571032/how- to-get-httpcontext-current-in-asp-net-core) –