1
我試圖讓我的MVC項目文件上載到服務器。我寫了我的課,C#MVC問題,文件上傳
public class MyModule: IHttpModule
which defines the event
void app_BeginRequest (object sender, EventArgs e)
In it, I check the length of the file that the user has selected to send.
if (context.Request.ContentLength> 4096000)
{
//What should I write here, that file is not loaded? I tried
context.Response.Redirect ("address here");
//but the file is still loaded and then going on Redirect.
}
你到底要做 - 檢查文件是否超過最大尺寸?另外,我不認爲你需要創建的IHttpModule的實現來處理文件上傳 - 你可以簡單地在你的控制器,需要一個HttpPostedFileBase參數使用[HttpPost]操作。 – Pandincus 2010-12-06 14:26:55