You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
695 B
32 lines
695 B
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace EC.Web
|
|
{
|
|
/// <summary>
|
|
/// 版 本 EasyCode EC管理后台
|
|
/// Copyright (c) 2019-present EC管理有限公司
|
|
/// 创建人:tobin
|
|
/// 日 期:2019.09.12
|
|
/// 描 述:对HttpRequest类进行扩展
|
|
/// </summary>
|
|
public static class HttpRequestExtensions
|
|
{
|
|
/// <summary>
|
|
/// 判断是否是ajax请求
|
|
/// </summary>
|
|
/// <param name="req"></param>
|
|
/// <returns></returns>
|
|
public static bool IsAjax(this HttpRequest req)
|
|
{
|
|
bool result = false;
|
|
|
|
var xreq = req.Headers.ContainsKey("x-requested-with");
|
|
if (xreq)
|
|
{
|
|
result = req.Headers["x-requested-with"] == "XMLHttpRequest";
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|