本文整理汇总了C#中IResponse.Write方法的典型用法代码示例。如果您正苦于以下问题:C# IResponse.Write方法的具体用法?C# IResponse.Write怎么用?C# IResponse.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IResponse
的用法示例。
在下文中一共展示了IResponse.Write方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override void Execute(IRequest req, IResponse res, object requestDto)
{
var authErrorMessage = "";
try
{
// Perform security check
if (CanExecute(req))
return;
}
catch (System.Exception ex)
{
authErrorMessage = ex.Message;
var message = string.Format("Blocked unauthorized request: {0} {1} by ip = {2} due to {3}",
req.Verb,
req.AbsoluteUri,
req.UserHostAddress ?? "unknown",
authErrorMessage);
Log.Error(message);
}
// Security failed!
var responseMessage = "You are not authorized. " + authErrorMessage;
res.StatusCode = (int)HttpStatusCode.Unauthorized;
res.StatusDescription = responseMessage;
res.AddHeader(HttpHeaders.WwwAuthenticate, string.Format("{0} realm=\"{1}\"", "", "custom api"));
res.ContentType = "text/plain";
res.Write(responseMessage);
res.Close();
}
示例2: Execute
public void Execute(IRequest httpReq, IResponse httpRes)
{
HostContext.AppHost.AssertFeatures(Feature.Metadata);
httpRes.ContentType = "text/xml";
var baseUri = httpReq.GetParentBaseUrl();
var optimizeForFlash = httpReq.QueryString["flash"] != null;
var operations = new XsdMetadata(HostContext.Metadata, flash: optimizeForFlash);
try
{
var wsdlTemplate = GetWsdlTemplate(operations, baseUri, optimizeForFlash, httpReq.ResolveBaseUrl(), HostContext.Config.SoapServiceName);
httpRes.Write(wsdlTemplate.ToString());
}
catch (Exception ex)
{
log.Error("Autogeneration of WSDL failed.", ex);
httpRes.Write("Autogenerated WSDLs are not supported "
+ (Env.IsMono ? "on Mono" : "with this configuration"));
}
}
示例3: ProcessRequest
public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
{
if (HostContext.ApplyCustomHandlerRequestFilters(httpReq, httpRes))
return;
if (textContents == null && bytes == null)
return;
httpRes.ContentType = contentType;
if (textContents != null)
httpRes.Write(textContents);
else if (bytes != null)
httpRes.OutputStream.Write(bytes, 0, bytes.Length);
httpRes.Flush();
httpRes.EndHttpHandlerRequest(skipHeaders: true);
}
示例4: ProcessRequest
/// <summary>
/// Only manage full page results
/// </summary>
/// <param name="httpReq"></param>
/// <param name="httpRes"></param>
/// <param name="operationName"></param>
public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
{
var path = httpReq.PathInfo;
string output;
switch (Path.GetFileNameWithoutExtension(path))
{
case "profiler-results":
output = Results(httpReq, httpRes);
break;
default:
output = NotFound(httpRes);
break;
}
httpRes.Write(output);
}
示例5: ProcessRequest
public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
{
var path = httpReq.PathInfo;
string output;
switch (Path.GetFileNameWithoutExtension(path))
{
//case "mini-profiler-jquery.1.6.2":
//case "mini-profiler-jquery.tmpl.beta1":
case "ssr-jquip.all":
case "ssr-includes":
output = Includes(httpReq, httpRes, path);
break;
case "ssr-results":
output = Results(httpReq, httpRes);
break;
default:
output = NotFound(httpRes);
break;
}
httpRes.Write(output);
}
示例6: ProcessRequest
public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
{
var response = this.RequestInfo ?? GetRequestInfo(httpReq);
response.HandlerFactoryArgs = HttpHandlerFactory.DebugLastHandlerArgs;
response.DebugString = "";
if (HttpContext.Current != null)
{
response.DebugString += HttpContext.Current.Request.GetType().FullName
+ "|" + HttpContext.Current.Response.GetType().FullName;
}
if (HostContext.IsAspNetHost)
{
var aspReq = (HttpRequestBase) httpReq.OriginalRequest;
response.GetLeftPath = aspReq.Url.GetLeftPart(UriPartial.Authority);
response.Path = aspReq.Path;
response.UserHostAddress = aspReq.UserHostAddress;
response.ApplicationPath = aspReq.ApplicationPath;
response.ApplicationVirtualPath = HostingEnvironment.ApplicationVirtualPath;
response.VirtualAbsolutePathRoot = VirtualPathUtility.ToAbsolute("/");
response.VirtualAppRelativePathRoot = VirtualPathUtility.ToAppRelative("/");
}
var json = JsonSerializer.SerializeToString(response);
httpRes.ContentType = MimeTypes.Json;
httpRes.Write(json);
}
示例7: ProcessRequest
public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
{
var response = this.RequestInfo ?? GetRequestInfo(httpReq);
response.HandlerFactoryArgs = HttpHandlerFactory.DebugLastHandlerArgs;
response.DebugString = "";
if (HttpContext.Current != null)
{
response.DebugString += HttpContext.Current.Request.GetType().FullName
+ "|" + HttpContext.Current.Response.GetType().FullName;
}
if (HostContext.IsAspNetHost)
{
var aspReq = (HttpRequestBase)httpReq.OriginalRequest;
response.GetLeftPath = aspReq.Url.GetLeftPart(UriPartial.Authority);
response.Path = aspReq.Path;
response.UserHostAddress = aspReq.UserHostAddress;
response.ApplicationPath = aspReq.ApplicationPath;
response.ApplicationVirtualPath = HostingEnvironment.ApplicationVirtualPath;
response.VirtualAbsolutePathRoot = VirtualPathUtility.ToAbsolute("/");
response.VirtualAppRelativePathRoot = VirtualPathUtility.ToAppRelative("/");
if (!Env.IsMono)
{
var userIdentity = aspReq.LogonUserIdentity;
if (userIdentity != null)
{
response.LogonUserInfo = new Dictionary<string, string> {
{ "Name", userIdentity.Name },
{ "AuthenticationType", userIdentity.AuthenticationType },
{ "IsAuthenticated", userIdentity.IsAuthenticated.ToString() },
{ "IsAnonymous", userIdentity.IsAnonymous.ToString() },
{ "IsGuest", userIdentity.IsGuest.ToString() },
{ "IsSystem", userIdentity.IsSystem.ToString() },
{ "Groups", userIdentity.Groups.Map(x => x.Value).Join(", ") },
};
var winUser = userIdentity.User;
if (winUser != null)
{
response.LogonUserInfo["User"] = winUser.Value;
response.LogonUserInfo["User.AccountDomainSid"] = winUser.AccountDomainSid != null
? winUser.AccountDomainSid.ToString()
: "null";
response.LogonUserInfo["User.IsAccountSid"] = winUser.IsAccountSid().ToString();
}
}
}
}
var json = JsonSerializer.SerializeToString(response);
httpRes.ContentType = MimeTypes.Json;
httpRes.Write(json);
httpRes.EndHttpHandlerRequest(skipHeaders:true);
}
示例8: WriteHeader
public void WriteHeader(IResponse response)
{
// TODO: Eventually I'd like to make this write as it goes instead of
// buffering into a stream, but I need to create the ResponseStream
// type first.
response.Write (ToHeaderString ());
}
示例9: ProcessRequest
public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
{
var response = this.RequestInfo ?? GetRequestInfo(httpReq);
response.HandlerFactoryArgs = HttpHandlerFactory.DebugLastHandlerArgs;
response.DebugString = "";
if (HttpContext.Current != null)
{
response.DebugString += HttpContext.Current.Request.GetType().FullName
+ "|" + HttpContext.Current.Response.GetType().FullName;
}
var json = JsonSerializer.SerializeToString(response);
httpRes.ContentType = MimeTypes.Json;
httpRes.Write(json);
}