ASP.NET Handler (.ashx) with long Query String Parameters

I want to know what is the best solution for creating ASP.NET HTTP Handler (.ashx) with long Query string parameters, as i have parameter like "description" which will be a long string which will make a problem in URL when access it by HTTP Request.

0

1 Answer

if you just want use GET method,you can't solved this problem,you can set it at What is the maximum length of a URL? why.

you can change you .ASHX file accept the POST method.

<httpHandler> <add path="1.ashx" verb="post" type="" />
</httpHandler>

your server-side code like this :

public void ProcessRequest(HttpContext context) { var stream = context.Request.InputStream; using (StreamReader sr = new StreamReader(stream)) { var text = sr.ReadToEnd(); } }

or alternative(based on your client-side how to send data)

 public void ProcessRequest(HttpContext context) { var text= context.Request.Form["text"]; }

your client-side:

 <script type="text/javascript"> $.ajax({ type: 'POST', url: "1.ashx", data: { name: "John", time: "2pm" } });
</script>
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like