0

I need to create a web service, in .NET, where a sender can send data, as query string, and the parameter names are encoded. Below is an example of the URL to send the data: http://hostname/Processor/Service.asmx/InsertReport?A%2dE3%2dName=John

The method InsertReport needs to have A-E3-Name as a parameter.

How do I declare the parameter to receive the value John?

kissta
  • 453
  • 1
  • 4
  • 8
  • Please keep in mind that when you're sending data in a query string, that there may be a maximum character limit depending on the server and/or browser. That's something to consider if you're going to host it with IIS. I would reference this answer to get an idea http://stackoverflow.com/questions/812925/what-is-the-maximum-possible-length-of-a-query-string#answer-812962 – Jeff LaFay Oct 09 '14 at 16:00

3 Answers3

1

You can retrieve query string parameter values in C# by:

Request.QueryString["A-E3-Name"]
robobot3000
  • 589
  • 2
  • 4
0
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<table class="table table-hover">
  <tr>
    <td>No</td>
    <td>Test1></td>
  </tr>
  <tr>
    <td>No</td>
    <td>Test2></td>
  </tr>
</table>
</body>
0

If you want to pass these in as actual parameters for your webmethod (eg. your ASMX has a method with parameters that correspond to your querystring parameter names), you need to rethink your parameter names. Even if you url-decoded them, you can't have a C# method with parameters named A-B-3-Something. Try creating a method with a parameter like that and you will notice that it won't compile.

Perhaps if you describe what you are trying to do we can offer a better solution.

DVK
  • 2,726
  • 1
  • 17
  • 20