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

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJocHBrZ26GeXvArKdmppWpeqmtzZ2jnqpdlsCpxIywoK2gXaG8r7OMqqyeqqliwLW%2ByKeeZqiRp66usdOeqaw%3D