Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
[HttpGet]
public IActionResult Create([FromHeader(Name = "x-requestid")] string requestId)
return View();
[HttpPost]
public IActionResult Create(Person person, [FromHeader(Name = "x-requestid")] string requestId)
if (ModelState.IsValid)
string test = "got here";
return View();
requestId is always null. How is requestId populated?
I have read lots of questions over the last two hours e.g. this one: What is the X-REQUEST-ID http header?. An answerer to another question suggesting installing the following Nuget package:
Microsoft.ApplicationInsights.ASPNetCore
However, this made no difference.
In general the "x-*" headers are non-standard ones.
That particular one is probably coincidentally used within Application Insights to uniquely identify a request, but it's unlikely to be sending requests to your server including it.
Whatever client is sending requests to your server has to be explicitly adding that header for you to receive it there; it's not part of any standard HTTP request.
–
You are bound to request header with name "x-requestid", but it should be called "X-Request-ID". Just try:
[HttpGet]
public IActionResult Get([FromHeader(Name = "x-request-id")] string requestId)
return View();
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.