繁体   English   中英

以注册Asp.NET身份上传

[英]Upload with Register Asp.NET Identity

我正在尝试编辑默认的Register方法,以在我的ASP.NET MVC 5应用程序中启用用户在注册过程中上传文件。 我已经将控制器编辑为:

public async Task<ActionResult> Register(RegisterViewModel model, HttpPostedFileBase file1, HttpPostedFileBase file2)
{
    if (ModelState.IsValid)
    {

鉴于我有这个:

<div class="form-group">
    <label class="control-label col-md-2" for="AssignmentPath">Assignment: </label>
<div class="col-md-10">
        <input id="AssignmentPath" title="Submit your assignment" type="file" name="file1" />

    </div>
</div>

    <div class="form-group">
        <label class="control-label col-md-2" for="FontPath">Font : </label>
<div class="col-md-10">
        <input id="FontPath" title="Submit your font" type="file" name="file2" />

    </div>
</div>

调试代码时,我发现Controller中的file1和file2均为空。 你能告诉我问题是什么吗? 谢谢。

您的观点应该是这样的

    @using (Html.BeginForm ("Index","Home", FormMethod.Post,  
                            new { enctype = "multipart/form-data" }))  
    {                    
         <input type="file" name="file1" />
         <input type="file" name="file2"/>
         <input type="submit" value="Upload file"/>
    } 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM