Reputation: 45
I have looked all over the net but cant seem to find a decent example.
In php we can use GET to pull in variables from the URL; how is this done in asmx?
[WebMethod(Description = "multiply two numbers")]
public int mul(int num1, int num2)
{
//num1 = Request.QueryString["num1"];
//num2 = Request.QueryString["num2"];
return num1 * num2;
}
I have inserted the following into the web.config file to enable GET:
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
Upvotes: 0
Views: 112
Reputation: 698
Server.Transfer("admin.aspx?SelectedView=view1", true);
You can get the passed variable using the above code.
String selectedView = Request.QueryString["SelectedView"];
Upvotes: 0
Reputation: 813
I am not sure how your calling the asmx client side, but on the web method you may need to add ScriptMethod specifying "GET" explicitly.
[WebMethod(Description = "multiply two numbers")]
[ScriptMethod(UseHttpGet = true)]
public int mul(int num1, int num2)
{
return num1 * num2;
}
Upvotes: 1
Reputation:
say the url is http://www.yoursite.com/default.aspx?stuff=2
to get stuff as parameter the code is
string stuff=Request.Params["stuff"];
Note that the value is stored as a string.
Upvotes: 1