本文整理汇总了C#中System.Web.HttpApplication.IsValidRequest方法的典型用法代码示例。如果您正苦于以下问题:C# HttpApplication.IsValidRequest方法的具体用法?C# HttpApplication.IsValidRequest怎么用?C# HttpApplication.IsValidRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpApplication
的用法示例。
在下文中一共展示了HttpApplication.IsValidRequest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Respond
public override void Respond(HttpApplication application, GlimpseConfiguration config)
{
if (!application.IsValidRequest(config, false, checkPath: false))
{
var data =
JsSerializer.Serialize(new { Error = true, Message = "You are not configured to access history." });
JsonResponse(application, data);
return;
}
var queue = application.Application[GlimpseConstants.JsonQueue] as Queue<GlimpseRequestMetadata>;
if (queue != null)
{
var filteredQueue = from request in queue
group request by request.ClientName
into clients
select new { Client = clients.Key, RequestCount = clients.Count() };
var data = JsSerializer.Serialize(filteredQueue);
JsonResponse(application, data);
return;
}
else
{
var data = JsSerializer.Serialize(new { Error = true, Message = "No history avalible." });
JsonResponse(application, data);
return;
}
}
示例2: Respond
public override void Respond(HttpApplication application, GlimpseConfiguration config)
{
if (!application.IsValidRequest(config, false, checkPath: false))
{
var data =
JsSerializer.Serialize(new { Error = true, Message = "You are not configured to access history." });
JsonResponse(application, data);
return;
}
var queue = application.Application[GlimpseConstants.JsonQueue] as Queue<GlimpseRequestMetadata>;
if (queue != null)
{
var result = new Dictionary<string, object>();
var sortedQueue = from request in queue orderby request.ClientName select request;
var lastClient = Guid.NewGuid().ToString();
foreach (var request in sortedQueue)
{
if (!lastClient.Equals(request.ClientName))
result.Add(request.ClientName, new Dictionary<string, object>());
var dictionary = result[request.ClientName] as IDictionary<string, object>;
dictionary.Add(request.RequestId.ToString(), new {request.Url, request.Browser, request.RequestTime, request.IsAjax, request.Method});
lastClient = request.ClientName;
}
var data = JsSerializer.Serialize(new {Data = result});
JsonResponse(application, data);
return;
}
else
{
var data = JsSerializer.Serialize(new { Error = true, Message = "No history avalible." });
JsonResponse(application, data);
return;
}
}
示例3: Respond
public override void Respond(HttpApplication application, GlimpseConfiguration config)
{
if (!application.IsValidRequest(config, false, checkPath: false))
{
var data =
JsSerializer.Serialize(new {Error = true, Message = "You are not configured to access history."});
JsonResponse(application, data);
return;
}
var queue = application.Application[GlimpseConstants.JsonQueue] as Queue<GlimpseRequestMetadata>;
if (queue != null)
{
var clientName = application.Request.QueryString[GlimpseConstants.ClientName];
string data;
if (string.IsNullOrEmpty(clientName))
data = JsSerializer.Serialize(queue);
else
{
var filteredQueue = from request in queue
where request.ClientName.Equals(clientName)
select request;
data = JsSerializer.Serialize(filteredQueue);
}
JsonResponse(application, data);
return;
}
else
{
var data = JsSerializer.Serialize(new {Error = true, Message = "No history avalible."});
JsonResponse(application, data);
return;
}
}
示例4: Respond
public override void Respond(HttpApplication application, GlimpseConfiguration config)
{
if (!application.IsValidRequest(config, false, checkPath: false))
{
var data =
JsSerializer.Serialize(new {Error = true, Message = "You are not configured to access history."});
JsonResponse(application, data);
return;
}
var queue = application.Application[GlimpseConstants.JsonQueue] as Queue<GlimpseRequestMetadata>;
if (queue != null)
{
var result = new Dictionary<string, object>();
IEnumerable<GlimpseRequestMetadata> data;
var requestId = application.Request.QueryString[GlimpseConstants.ClientRequestId];
if (!string.IsNullOrEmpty(requestId))
{
data = from request in queue
where request.RequestId.ToString().Equals(requestId)
select request;
var requestResult = data.FirstOrDefault();
if (requestResult != null)
result.Add(requestResult.RequestId.ToString(), new { Data = requestResult.Json });
}
else
{
var clientName = application.Request.QueryString[GlimpseConstants.ClientName];
if (string.IsNullOrEmpty(clientName))
data = queue;
else
{
data = from request in queue
where request.ClientName.Equals(clientName)
select request;
}
var lastClient = Guid.NewGuid().ToString();
foreach (var request in data.OrderBy(d => d.ClientName))
{
if (!lastClient.Equals(request.ClientName))
result.Add(request.ClientName, new Dictionary<string, object>());
var dictionary = result[request.ClientName] as IDictionary<string, object>;
dictionary.Add(request.RequestId.ToString(), new { Data = request.Json });
lastClient = request.ClientName;
}
if (!string.IsNullOrEmpty(clientName) && result.Count == 0)
result.Add(clientName, new Dictionary<string, object>());
}
var json = JsSerializer.Serialize(new { Data = result });
JsonResponse(application, json);
return;
}
else
{
var data = JsSerializer.Serialize(new {Error = true, Message = "No history avalible."});
JsonResponse(application, data);
return;
}
}