本文整理汇总了C#中Microsoft.AspNet.Http.HttpResponse.WriteAsync方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponse.WriteAsync方法的具体用法?C# HttpResponse.WriteAsync怎么用?C# HttpResponse.WriteAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.AspNet.Http.HttpResponse
的用法示例。
在下文中一共展示了HttpResponse.WriteAsync方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteResponseBodyAsync
internal static Task WriteResponseBodyAsync(HttpResponse response, string uid, DateTimeOffset? datetime, TimeSpan? duration, string summary, string description, string location) {
return response.WriteAsync(
"BEGIN:VCALENDAR\r\n" +
"VERSION:2.0\r\n" +
"BEGIN:VEVENT\r\n" +
"UID:" + uid + "\r\n" +
"DTSTART:" + datetime?.ToString(DateTimeFormat) + "\r\n" +
"DTEND:" + datetime?.Add(duration ?? TimeSpan.Zero).ToString(DateTimeFormat) + "\r\n" +
"SUMMARY:" + summary + "\r\n" +
"DESCRIPTION:" + description + "\r\n" +
"LOCATION:" + location +
"END:VEVENT\r\n" +
"END:VCALENDAR\r\n");
}
示例2: WriteOutput
public static async Task WriteOutput(HttpResponse Response, string Title, Head.Tag[] HeadTags, string Body) {
var sb = new StringBuilder();
sb.Append("<!DOCTYPE html><head><meta charset=\"utf-8\">");
if (Title != null) {
sb.Append("<title>" + Title + "</title>");
}
if (HeadTags != null) {
foreach (var a in HeadTags) {
sb.Append(a.Output());
}
}
sb.Append("</head><body>");
sb.Append(Body);
sb.Append("</body></html>");
await Response.WriteAsync(sb.ToString());
}
示例3: WriteOtherSettingsAsync
public async Task WriteOtherSettingsAsync(HttpResponse response)
{
await response.WriteAsync(
$"OtherSettings Strings: {string.Join(", ", _otherSettings.Strings)}<br>" +
$"OtherSettings Numbers: {string.Join(", ", _otherSettings.Numbers)}");
}
示例4: Json
private async Task Json(HttpResponse Response, Site.Page Page) {
Response.ContentType = "text/javascript";
var s = @"{""title"":""" + Util.Json.Fix(Page.Title) + @""",""description"":""" + Util.Json.Fix(Page.Description) + @""",""header"":""" + Util.Json.Fix(Page.Header) + @""",""key"":""" + Page.Key + @""",""content"":""" + Util.Json.Fix(Page.Content) + @"""}";
await Response.WriteAsync(s);
}
示例5: Javascript
private async Task Javascript(HttpResponse Response) {
Response.Headers.Add(Headers.Cache, Headers.Values.Cache);
Response.ContentType = "text/javascript";
if (_javascript == null) {
_javascript = await Util.File.LoadToString("_files/js/this.js");
}
await Response.WriteAsync(_javascript);
}
示例6: Css
private async Task Css(HttpResponse Response) {
Response.Headers.Add(Headers.Cache, Headers.Values.Cache);
Response.ContentType = "text/css";
if (_css == null) {
_css = await Util.File.LoadToString("_files/css/this.css");
}
await Response.WriteAsync(_css);
}
示例7: WritePageFooter
private async Task WritePageFooter(HttpResponse response)
{
await response.WriteAsync("</body>");
await response.WriteAsync("</html>");
//response.Flush();
}
示例8: WritePageHeader
private async Task WritePageHeader(HttpResponse response)
{
string setupTemplatePath = setupOptions.SetupHeaderConfigPath.Replace("/", Path.DirectorySeparatorChar.ToString());
if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft)
{
setupTemplatePath = setupOptions.SetupHeaderConfigPathRtl.Replace("/", Path.DirectorySeparatorChar.ToString());
}
//string fsPath = hostingEnvironment.MapPath(setupTemplatePath);
string fsPath = appBasePath + setupTemplatePath;
if (System.IO.File.Exists(fsPath))
{
string sHtml = string.Empty;
using (StreamReader oStreamReader = System.IO.File.OpenText(fsPath))
{
sHtml = oStreamReader.ReadToEnd();
}
await response.WriteAsync(sHtml);
}
//response.Flush();
}
示例9: WritePageContent
private async Task WritePageContent(HttpResponse response, string message, bool showTime)
{
if (showTime)
{
await response.WriteAsync(
string.Format("{0} - {1}",
message,
DateTime.UtcNow.Subtract(startTime)));
}
else
{
await response.WriteAsync(message);
}
await response.WriteAsync("<br/>");
//response.Flush();
}
示例10: WriteErrorToResponse
private static async Task WriteErrorToResponse(HttpResponse response, string error)
{
response.StatusCode = (int)HttpStatusCode.BadRequest;
response.Headers.Add("Pragma", new[] { "no-cache" });
response.Headers.Add("Cache-Control", new[] { "no-cache" });
response.ContentType = "text/plain";
// Padding to >512 to ensure IE doesn't hide the message
// http://stackoverflow.com/questions/16741062/what-rules-does-ie-use-to-determine-whether-to-show-the-entity-body
await response.WriteAsync(error.PadRight(513));
}
示例11: WriteInstalledSchemaSummary
private async Task WriteInstalledSchemaSummary(HttpResponse response)
{
//await WritePageContent(response, message, false);
List<VersionItem> currentSchemas = await setupManager.GetInstalledSchemaList();
await response.WriteAsync("<h2>Current Schema Versions</h2>");
await response.WriteAsync("<ul>");
string formatString = "<li>{0} - {1}</li>";
foreach(VersionItem item in currentSchemas)
{
string itemMarkup = string.Format(formatString, item.Name, item.CurrentVersion.ToString());
await response.WriteAsync(itemMarkup);
}
await response.WriteAsync("</ul>");
}
示例12: FileNotFound
public static async Task FileNotFound(HttpResponse Response) {
Response.StatusCode = 404;
await Response.WriteAsync("File Not Found");
}