本文整理汇总了C#中IHttpContext.SetStatusTo方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpContext.SetStatusTo方法的具体用法?C# IHttpContext.SetStatusTo怎么用?C# IHttpContext.SetStatusTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHttpContext
的用法示例。
在下文中一共展示了IHttpContext.SetStatusTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequestInner
public void ProcessRequestInner(IHttpContext context)
{
var sw = Stopwatch.StartNew();
try
{
DispatchRequestToHandlers(context);
}
catch (Exception e)
{
HandleException(context, e);
context.SetStatusTo(HttpStatusCode.InternalServerError);
}
finally
{
context.TryCloseResponse();
var curReq = Interlocked.Increment(ref _requestNumber);
Trace.WriteLine(string.Format("Request #{0,4:#,0}: {1,-7} - {2,5:#,0} ms - {3} - {4}",
curReq, context.Request.HttpMethod, sw.ElapsedMilliseconds, context.Response.StatusCode,
context.Request.Url.PathAndQuery));
}
}
示例2: Handle
public override void Handle(IHttpContext context)
{
var stream = context.Response.OutputStream;
Resources.favicon.Save(stream);
stream.Flush();
context.SetStatusTo(HttpStatusCode.OK);
}
示例3: Handle
public override void Handle(IHttpContext context)
{
_mouseStats.RefreshStatistics();
var data = JsonSerializer.SerializeToString(_mouseStats);
context.Response.ContentType = "application/json";
context.WriteString(data);
context.SetStatusTo(HttpStatusCode.OK);
}
示例4: Handle
public override void Handle(IHttpContext context)
{
var msg = new EnvelopeBuilder(Guid.NewGuid().ToString());
var contract = context.GetRequestUrl().Remove(0,"/send/".Length);
Type contractType;
if (!_serializer.TryGetContractTypeByName(contract, out contractType))
{
context.WriteString(string.Format("Trying to post command with unknown contract '{0}'.", contract));
context.SetStatusTo(HttpStatusCode.BadRequest);
return;
}
_writer.PutMessage(_streamer.SaveEnvelopeData(msg.Build()));
context.WriteString(string.Format(@"
Normally this should be a JSON POST, containing serialized data for {0}
but let's pretend that you successfully sent a message. Or routed it", contractType));
context.SetStatusTo(HttpStatusCode.OK);
}
示例5: Handle
public override void Handle(IHttpContext context)
{
var contract = context.GetRequestUrl().Remove(0, "/mouseevents/".Length);
var envelopeBuilder = new EnvelopeBuilder(contract + " - " + DateTime.Now.Ticks.ToString());
Type contractType;
if (!_serializer.TryGetContractTypeByName(contract, out contractType))
{
context.WriteString(string.Format("Trying to post command with unknown contract '{0}'.", contract));
context.SetStatusTo(HttpStatusCode.BadRequest);
return;
}
var decodedData = HttpUtility.UrlDecode(context.Request.QueryString.ToString());
var mouseEvent = JsonSerializer.DeserializeFromString(decodedData, contractType);
envelopeBuilder.AddItem(mouseEvent);
_writer.PutMessage(_streamer.SaveEnvelopeData(envelopeBuilder.Build()));
context.SetStatusTo(HttpStatusCode.OK);
}
示例6: Handle
public override void Handle(IHttpContext context)
{
var view = _reader.Get(unit.it);
if (view.HasValue)
{
if (context.GetRequestUrl().Contains("thumb"))
{
view.Value.Thumbnail.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}
else
{
view.Value.Heatmap.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}
}
else
{
ReturnEmptyImage(context);
}
context.SetStatusTo(HttpStatusCode.OK);
}
示例7: DispatchRequestToHandlers
void DispatchRequestToHandlers(IHttpContext context)
{
foreach (var requestResponder in _handlers)
{
if (requestResponder.WillHandle(context))
{
requestResponder.Handle(context);
return;
}
}
context.SetStatusTo(HttpStatusCode.BadRequest);
if (context.Request.HttpMethod == "HEAD")
return;
context.WriteString(
@"
<html>
<body>
<h1>Bad Request</h1>
<p>Mea culpa, <a href='http://lokad.github.com/lokad-cqrs/'>Lokad.Cqrs</a> Http server
does not know, how to handle this request.</p>
</body>
</html>
");
}