From swagger screenshotwhen I am trying to post files from swagger or postman it is working fine. When i am trying to call api from mvc web app it is not working.I am new to asp.net core,there is no error showing but the api controller is not hitting here is the mvc controller code
public async Task<PostViewModel> AddPost(PostViewModel model)
{
TestViewModel testViewModel = new TestViewModel()
{
Description = model.Description,
Files = model.Files[0],
};
var formContent = new MultipartFormDataContent();
formContent.Add(new StringContent(testViewModel.Description), "Description");
formContent.Add(new StreamContent(testViewModel.Files.OpenReadStream()), "Files", Path.GetFileName(testViewModel.Files.FileName));
HttpClient hc = new HttpClient();
hc.BaseAddress = new Uri("baseurl");
var response = await hc.PostAsync("PostFile", formContent);
string apiResponse = await response.Content.ReadAsStringAsync();
return null;
//...
}`
my api controller
[HttpPost("PostFile", Name = "PostFile")]
public async Task<IActionResult> PostFile([FromForm] TestViewModel testViewModel)
{
Console.Write("Hello");
return null;
}
