Avatar of Keith McElroy
Keith McElroy

asked on 

ashx c# GET works, POST fails

I want to upgrade this file to POST instead of GET and have hit a problem.

The following code works if Method is "GET" and fails if "POST"


Error is:

Error Information: Unhandled Exception



<%@WebHandler Language="C#" Class="APIHandler"%>






using System;
using System.Web;
using System.Xml;

using System.Net;
using System.IO;
using System.Text;

using System.Collections;
using System.Collections.Specialized;


public class APIHandler:IHttpHandler
{
   public bool IsReusable{get{return true;}}


   public void ProcessRequest(HttpContext context){


      HttpRequest request=context.Request;
      HttpResponse response=context.Response;

     
      String URLreq = "http://172.18.129.120/connect/default.asp"   ;

      HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URLreq);
      myRequest.Method = "POST";
      WebResponse myResponse = myRequest.GetResponse();



   
   }



}



C#HTTP Protocol

Avatar of undefined
Last Comment
louisfr

8/22/2022 - Mon