How to Display Request Headers in Asp.Net Razor Pages

When troubleshooting a web page, one thing you may find yourself wanting is to see all the response headers. There is a program/site named PostMan that will do this for you. This is helpful if you are running ASP.Net as a reverse proxy under Apache and suspect some headers aren't coming you are expecting.

This little diddy put in your model file OnGet() method of a Razor page will dump them into a model variable named the_uid. You then reference this in your HTML page with @Html.Raw(Model.the_uid).

//using System.Net.Http;
//using System.Reflection;
...
public string the_uid=String.Empty; 

public void OnGet()
{
var headers = new HttpClient().DefaultRequestHeaders;
PropertyInfo[] properties = headers.GetType().GetProperties();
foreach (var property in properties)
	the_uid+="<b>"+property.Name + "</b>: <i>" + Request.Headers[property.Name] + "</i><br/>";
}
...