宿主 public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webB
我们可以通过HTTP请求头来判断是否为Ajax请求,Ajax请求的request headers里都会有一个key为x-requested-with,值为XMLHttpRequest的header 所以我们可以添加一个扩展方法: public static bool IsAjax(this HttpRequest req) { bool result = false; var xreq = req.Headers.ContainsKey("x-requested-with"); if