asp.net mvc 4 - Instances of abstract classes cannot be created when uploading -
when try upload('xlsx','csv') format, invalidoperationexception: instances of abstract classes cannot created.
here controller
public actionresult upload() { return view(); } [httppost] public actionresult upload(httppostedfilebase fileupload) { if (fileupload.contentlength > 0) { string filename = path.getfilename(fileupload.filename); string path = path.combine(system.web.httpcontext.current.server.mappath("~/app_data/uploads"), filename); try { fileupload.saveas(path); viewdata["feedback"] = "upload complete"; } catch (exception ex) { viewdata["feedback"] = ex.message; } } return view("upload", viewdata["feedback"]); } here view
@{ viewbag.title = "file"; } <h2>upload file</h2> @using (html.beginform("upload", "ofnpage", formmethod.post, new { enctype = "multipart/form-data" })) { <input type="file" name="fileupload" /> <input type="submit" name="submit" id="submit" value="upload" /> <br><br> @viewbag.message } can me edit or guide me troubleshoot them?
Comments
Post a Comment