35 lines
931 B
C#
35 lines
931 B
C#
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
using System;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNet.Http;
|
|
|
|
namespace Microsoft.AspNet.Mvc
|
|
{
|
|
public class ContentResult : ActionResult
|
|
{
|
|
public string Content { get; set; }
|
|
|
|
public Encoding ContentEncoding { get; set; }
|
|
|
|
public string ContentType { get; set; }
|
|
|
|
public override async Task ExecuteResultAsync([NotNull] ActionContext context)
|
|
{
|
|
var response = context.HttpContext.Response;
|
|
|
|
if (!string.IsNullOrEmpty(ContentType))
|
|
{
|
|
response.ContentType = ContentType;
|
|
}
|
|
|
|
if (Content != null)
|
|
{
|
|
await response.WriteAsync(Content);
|
|
}
|
|
}
|
|
}
|
|
}
|