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
Sourav Kumar Das
525
2.5k
171.3k
WEB API consuming in MVC is throwing an error?
Dec 31 2019 1:26 AM
Hi All,
I have a question in WEB Api consuming in MVC is throwing an error, like "Time outs are not supported on this stream"
public
async Task<ActionResult> InsertVendorDetails(Vendor V)
{
Session[
"UserId"
] =
"1001"
;
if
(V.FirstName != null && V.LastName != null && V.MobileNo != null && V.UserName != null && V.Address != null && V.IDProof != null && V.EmailId != null && V.Password != null)
{
HttpClient client =
new
HttpClient();
client.BaseAddress =
new
Uri(Baseurl);
//client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Accept.Clear();
V.CreatedBy = Session[
"UserId"
].ToString();
HttpResponseMessage response = await client.PostAsJsonAsync(
"NewVendorRegistration"
, V);
if
(response.IsSuccessStatusCode ==
true
)
{
var vendorresponse = response.Content.ReadAsStringAsync().Result;
var StatusCode = JObject.Parse(vendorresponse)[
"StatusCode"
].ToString();
if
(StatusCode ==
"1"
)
{
return
RedirectToAction(
"GetVendor"
,
"SmartParkingApplication"
);
}
else
{
var Response = JObject.Parse(vendorresponse)[
"Response"
].ToString();
ModelState.AddModelError(string.Empty, Response.ToString());
}
}
else
{
ModelState.AddModelError(string.Empty,
"Server Error.Please contact administrator."
);
}
return
View();
}
return
View();
}
At Line no : 12
while running in postman it's consuming correctly but in mvc it's not running.
If there's a solution please let me know it as soon as possible.
Reply
Answers (
3
)
how to bind the dropdownlist after the form is post .
WEB API code how to consume it in ASP.Net MVC