I am looking for a solution on how to send a file using a form to an asp application. I am writing in the asp .net framework MVC Razor.
My form:
<div class="container">
    <div class="col-md-2">
        @using (Html.BeginForm("Data", "Admin", FormMethod.Post, new { encrypte = "multipart/form-data"}))
        {
            <div class="form login-form">
                <label for="username" class="text-info">Wczytaj plik:</label>
                <input type="file" name="file" id="file" />
            </div>
            <div id="register-link" class="text-right">
                <input type="submit" class="btn btn-success" value="Importuj" />
            </div>
            @ViewBag.Message
        }
    </div>
</div>
My controller:
        [HttpPost]
        public ViewResult Data(HttpPostedFile file = null)
        {
            if(file != null && file.ContentLength > 0)
            {
                string path = Path.Combine(Server.MapPath("~/Upload/Data"), Path.GetFileName(file.FileName));
                file.SaveAs(path);
                ViewBag.Message = "Succes";
            }
            return View("AdminDataView", students);
        }
Unfortunately, the above code does not work, am I doing something wrong with it, is there another option to upload the file to asp?