Last post Dec 28, 2015 08:17 AM by nideeshm
Dec 22, 2015 06:51 PM|rvgraham123|LINK
I am trying to build a new Intranet site, hopefully free of MVC and WCF, both of which I don't like and don't want to know anything about.
I want to start with an empty template with Web Forms/Web API checked. (So I can fall back on Web Forms here and there although I have long since abandoned the Post-back life-cycle in favor of JQuery/Ajax calling ASMX web services.)
I have three early road blocks.
I already have my code for working with the Excel file and creating the JSON I want to return (that used to be in code-behind or in ASMX services), I just haven't successfully wired up the web form (an HTML page would be OK if that's easier) to post back
to the controller, especially since the routes are never called.
I have found good example code about handling a file upload in a controller, just don't understand yet how to connect the dots (that example was in a console application).
This is for conventional line-of-business development, dealing with a scheduling app, so I'm trying to learn exciting stuff to deal with the boredom of *what* I do.
I'm using EF 6 and already have my Models, edmx file and database working and ready. (None of these are new to me.)
Please help a veteran coder get away from ASMX and get RESTful
Dec 28, 2015 03:52 AM|Kelmen|LINK
just giving a tip about ur "idiot" question: web api is based on mvc. since u have no interest to pick mvc up, looks like u have to drop web api.
Dec 28, 2015 08:17 AM|nideeshm|LINK
file uploading in web API.
public async Task<HttpResponseMessage> PostStuff()
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
var root = HttpContext.Current.Server.MapPath("~/App_Data/Temp/FileUploads");
var provider = new MultipartFormDataStreamProvider(root);
var result = await Request.Content.ReadAsMultipartAsync(provider);
if (result.FormData["model"] == null)
throw new HttpResponseException(HttpStatusCode.BadRequest);
var model = result.FormData["model"];
//TODO: Do something with the json model which is currently a string
//get the files
foreach (var file in result.FileData)
//TODO: Do something with each uploaded file
return Request.CreateResponse(HttpStatusCode.OK, "success!");
in a single request. This i have succesfully used in my project. I have tryied to upload PDF, zip files it is working superb.