Created
June 30, 2009 15:53
-
-
Save rafaelss/138225 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Mvc; | |
/* | |
* return new SimpleResult("Hello World"); | |
* return new SimpleResult(1); | |
* return new SimpleResult(1257.14); | |
* return new SimpleResult(true); | |
*/ | |
namespace Custom.Mvc | |
{ | |
public class SimpleJsonResult : ActionResult | |
{ | |
private JsonResult result = new JsonResult(); | |
public SimpleJsonResult(object content) | |
{ | |
result.ContentType = "text/javascript"; | |
result.Data = content; | |
} | |
public override void ExecuteResult(ControllerContext context) | |
{ | |
result.ExecuteResult(context); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Mvc; | |
/* | |
* return new SimpleJsonResult(new { success = true }); | |
*/ | |
namespace Custom.Mvc | |
{ | |
public class SimpleResult : ActionResult | |
{ | |
private ContentResult result = new ContentResult(); | |
public SimpleResult(string content) | |
{ | |
result.Content = content; | |
} | |
public SimpleResult(int content) | |
{ | |
result.Content = content.ToString(); | |
} | |
public SimpleResult(double content) | |
{ | |
result.Content = content.ToString(); | |
} | |
public SimpleResult(bool content) | |
{ | |
result.Content = content ? "true" : "false"; | |
} | |
public override void ExecuteResult(ControllerContext context) | |
{ | |
result.ExecuteResult(context); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment