我正在使用asp.net mvc框架。並試圖在回發請求後保存控件的狀態。簡單控件(文本框等)的值可以很容易地從請求中獲取,但是如何從窗體中獲得控制器端文件輸入控件的值。 令形式爲在mvc中保存文件上傳控件的狀態
@using(@Html.BeginForm("method","controller",new{enctype="multiple/form-data"}))
{
@Html.TextBox("Name")
<input type="file" name="f1" id="f1" />
}
和控制器是
[Httppost]
public ActionResult method()
{
ViewBag.Name=Request["Name"]
//here i have to get value of file-control i.e. path contained in it, to store in ViewBag
}
如何獲得價值從請求(文件即路徑)。 請幫忙。