0
我試圖在線重新創建數千個簡單示例,並且每次都失敗。MVC2 HttpPostedFileBase對象始終是空的
我在做什麼錯?
Other.aspx
<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master"
繼承= 「System.Web.Mvc.ViewPage」 %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent"
RUNAT = 「服務器」> 其他
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent"
RUNAT = 「服務器」>
<h2>Upload A File</h2> <% Html.BeginForm("UploadFile", "Home")%> <input type="file" name="f" /> <input type="submit" /> <% Html.EndForm()%> </form> </asp:Content>
- HomeController.vb
_ 公共類的HomeController 繼承System.Web.Mvc.Controller
Function Index() As ActionResult ViewData("Message") = "Welcome to ASP.NET MVC!" Return View() End Function Function About() As ActionResult Return View() End Function <HttpPost()> _ Sub UploadFile(f As HttpPostedFileBase) <---Breakpoint here, f is always "Nothing" RedirectToAction("Other") End Sub Function Other() As ActionResult Return View() End Function End Class
我似乎無法找到一個使用vb.net的示例 – 2011-05-23 18:14:21
我都沒有,vb.net中的匿名類似乎是問題所在。儘管您始終可以使用
使用C#會是明智嗎?我只是點擊了小MVC2嚮導,並沒有真正關心它選擇。 – 2011-05-23 18:32:00