Move GetRequestParm and ResponseObject to extension methods

This commit is contained in:
2015-09-29 07:11:10 +02:00
parent d2ad4c4692
commit 30f9225cc4
5 changed files with 74 additions and 92 deletions

View File

@@ -0,0 +1,33 @@
using System.Web;
using VAR.Focus.Web.Code.JSON;
namespace VAR.Focus.Web.Code
{
public static class ExtensionMethods
{
#region HttpContext
public static string GetRequestParm(this HttpContext context, string parm)
{
foreach (string key in context.Request.Params.AllKeys)
{
if (string.IsNullOrEmpty(key) == false && key.EndsWith(parm))
{
return context.Request.Params[key];
}
}
return string.Empty;
}
public static void ResponseObject(this HttpContext context, object obj)
{
var jsonWritter = new JSONWriter(true);
context.Response.ContentType = "text/json";
string strObject = jsonWritter.Write(obj);
context.Response.Write(strObject);
}
#endregion
}
}