TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
nitin somal
NA
38
9.8k
Upload file with model in Asp.net web api using fiddler
Jan 6 2020 9:30 AM
I have the following Web API end point:
[System.Web.Http.HttpPost]
public AddEvidenceResponseModel UploadCameraDetail(ABC1 model1){
string fileSaveLocation = HttpContext.Current.Server.MapPath("~/Evidence"); CustomMultipartFormDataStreamProvider provider = new CustomMultipartFormDataStreamProvider(fileSaveLocation); List files = new List(); Request.Content.ReadAsMultipartAsync(provider);
foreach (MultipartFileData file in provider.FileData) { files.Add(Path.GetFileName(file.LocalFileName));
}
}
In which I am uploading the txt file with model1 parameter. To hit this web api endpoint I am using fiddler with the following
Request Header: Content-Type: application/json,multipart/form-data,text/plain; boundary=-------------------------acebdf13572468 Host: localhost:53760 Content-Length: 360
Request Body: ---------------------------acebdf13572468 Content-Disposition: form-data; name="model1" Content-Type: application/json,multipart/form-data
{"MyProperty1":"tt"} ---------------------------acebdf13572468 Content-Disposition: form-data; name="fieldNameHere"; filename="A.txt" Content-Type: text/plain
<@INCLUDE C:\Users\Nitin.Singh\Desktop\Images\A.txt@> ---------------------------acebdf13572468--
Problem
: I am not able to get the value of model1 parameter and txt file value inside the web api end point method
Reply
Answers (
1
)
Animation portfolio free website Templates Download
async Action Result does not end