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
ahmed elbarbary
NA
1.6k
271.3k
How to pass number from angular to web api when action post asp.net c
May 27 2021 3:18 PM
I work on asp.net core 3.1 web api server side
and angular 7 client side
I work on page make upload to single file and it is ok working but when try to pass Number flag with file uploaded
I face issue I can't pass value of variable selectedOwnerLevel from angular 7 to web api
selectedOwnerLevel: number = 1;
suppose selectedOwnerLevel is have value 1
so How to pass value 1 to web api
on angular 7 client side
public
uploadFile = (files,selectowner) => {
const
formData =
new
FormData();
formData.append(
'file'
,
this
.fileToUpload,
this
.fileToUpload.name);
console.log(
this
.selectedOwnerLevel); // it have here 5
if
(
this
.selectedOwnerLevel==1)
{
this
.http.post(
'http://localhost:61265/api/DeliverySys/'
, formData,{ responseType:
'blob'
})
.subscribe((response: Blob) => saveAs(response,
this
.fileToUpload.name +
'.xlsx'
));
}
}
on html :
<div
class
=
"form-group"
>
<label
for
=
"file"
>Choose File</label>
<input type=
"file"
id=
"file"
(change)=
"handleFileInput($event.target.files)"
>
<button type=
"button"
class
=
"btn btn-success"
(click)=
"uploadFile(files,
this
.selectedOwnerLevel
)"
>Upload File</button>
</div>
on server side web api
[HttpPost, DisableRequestSizeLimit]
public
IActionResult Upload(int
selectedOwnerLevel
)
{
try
{
var DisplayFileName = Request.Form.Files[0];
string
fileName = DisplayFileName.FileName.Replace(
".xlsx"
,
"-"
) + Guid.NewGuid().ToString() +
".xlsx"
;
}
catch
(Exception ex)
{
return
StatusCode(500, $
"Internal server error: {ex}"
);
}
when debug value of
selectedOwnerLevel it display as 0
so please How to display as actual value 1 on angular 7 ?
when do consol.log (
this
.selectedOwnerLevel
) it give me 1 on image below
but it display 0
so How to solve issue please ?
thanks
Reply
Answers (
3
)
client side encrypt password
How to show data in DataTable