Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Diagnostics;
- using System.Web;
- using System.IO;
- using Newtonsoft.JSON; // Use the JSON.NET library from NuGet in your project here!
- public class InputObject
- {
- // Put each parameter you are passing from client side here
- // Can use arrays + more
- // Read up details in JSON.NET library documentation
- public string ParameterOne;
- public string ParameterTwo;
- }
- public class OutputObject
- {
- // Put each parameter you are passing back to client side here
- // Can you use arrays + more
- // Read up details in JSON.NET library documentation
- public string ParameterOne;
- public string ParameterTwo;
- }
- public class Handler1 : System.Web.IHttpHandler
- {
- public void ProcessRequest(HttpContext context)
- {
- InputObject input = JsonConvert.DeserializeObject<InputObject>(StreamToString(context.Request.InputStream));
- OutputObject resultObject = null;
- // populate your resultObject here by fetching data from the database
- context.Response.ContentType = "text/json";
- context.Response.Write(JsonConvert.SerializeObject(resultObject));
- }
- public bool IsReusable {
- get { return false; }
- }
- private string StreamToString(Stream target)
- {
- string resultString = "";
- using (StreamReader reader = new StreamReader(target)) {
- resultString = reader.ReadToEnd();
- }
- return resultString;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement