I am trying to pass lots of parameters to a controller and getting stuck.
What I have tried:
Build a long url and use navigationManager.NavigateTo
This works and downloads the file(word doc)
string URLString = String.Join("/",
document.TemplateID,
WebUtility.UrlEncode(document.mainText),
WebUtility.UrlEncode(document.DateValue),
WebUtility.UrlEncode(document.SalutationValue),
WebUtility.UrlEncode(document.BodyValue),
WebUtility.UrlEncode(document.refValue),
WebUtility.UrlEncode(document.SignatureValue),
WebUtility.UrlEncode(document.FileName));
navigationManager.NavigateTo("api/My/GenerateDocxBrowser/" + URLString, true);
But I want to pass an large number of parameters so I tried:
HttpClient client = new HttpClient();
var json = JsonConvert.SerializeObject(Doc);
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri(navigationManager.BaseUri + "api/My/GenerateDocxBrowser"),
Content = new StringContent(json, Encoding.UTF8, "application/json")
};
var response = client.SendAsync(request).ConfigureAwait(true);
var responseInfo = response.GetAwaiter().GetResult();
Controller
public IActionResult GenerateDocxBrowser([FromBody]DocumentModel docM)
etc....
But although this gets to the controller and I can access the parameters method works no file is downloaded.
What am i missing?