Merge pull request #151 from sornaks/WebFX153

WebFX-153: Add Content() and Json() to the Controller class.
This commit is contained in:
Sornakumar 2014-03-31 15:03:56 -07:00
commit e8a76cfd7f
3 changed files with 36 additions and 2 deletions

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Text;
using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.Rendering;
namespace Microsoft.AspNet.Mvc namespace Microsoft.AspNet.Mvc
@ -31,6 +32,16 @@ namespace Microsoft.AspNet.Mvc
}; };
} }
public IActionResult Content(string value, string contentType, Encoding contentEncoding)
{
return new ContentResult
{
Content = value,
ContentType = contentType,
ContentEncoding = contentEncoding
};
}
public IJsonResult Json(object value) public IJsonResult Json(object value)
{ {
return new JsonResult(value); return new JsonResult(value);

View File

@ -1,4 +1,5 @@
using Microsoft.AspNet.Abstractions; using System.Text;
using Microsoft.AspNet.Abstractions;
using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.Rendering;
@ -76,5 +77,25 @@ namespace Microsoft.AspNet.Mvc
return Result.View(view, ViewData); return Result.View(view, ViewData);
} }
public IActionResult Content(string content)
{
return Content(content, contentType: null);
}
public IActionResult Content(string content, string contentType)
{
return Content(content, contentType, contentEncoding: null);
}
public IActionResult Content(string content, string contentType, Encoding contentEncoding)
{
return Result.Content(content, contentType, contentEncoding);
}
public IJsonResult Json(object value)
{
return Result.Json(value);
}
} }
} }

View File

@ -1,4 +1,5 @@
using Microsoft.AspNet.Mvc.Rendering; using System.Text;
using Microsoft.AspNet.Mvc.Rendering;
namespace Microsoft.AspNet.Mvc namespace Microsoft.AspNet.Mvc
{ {
@ -6,6 +7,7 @@ namespace Microsoft.AspNet.Mvc
{ {
IActionResult Content(string value); IActionResult Content(string value);
IActionResult Content(string value, string contentType); IActionResult Content(string value, string contentType);
IActionResult Content(string value, string contentType, Encoding contentEncoding);
IJsonResult Json(object value); IJsonResult Json(object value);
IActionResult View(string view, ViewDataDictionary viewData); IActionResult View(string view, ViewDataDictionary viewData);
} }