Description: Using the JSON RPC call method in asp.net application to get the return value
1, vs new empty asp.net application, here. NET Framework Selection 4.0 +
2, download the latest version of the json-rpc.net asp.net package
Address:
http://jsonrpc2.codeplex.com/releases/view/100345
The json-rpc.net Server 1.0.3 is downloaded here
3, the introduction of the following two documents
4, at the same time to introduce
Otherwise, the project debug run will be wrong
Download Address http://json.codeplex.com/
The current project is introducing NET version 4.0
5, add the corresponding HTTP Handler in the Web.config file
Server (asp.net development server) or IIS6 add the following to the <system.web> tag
If the debug server is IIS 7 or above, add the following to the <system.webServer> tab
6, the next step is to create a new test class, and inherit from the Jsonrpcservice class, and introduce the corresponding namespace using Austinharris.jsonrpc;
public class helloworldservice:jsonrpcservice{
}
7. Add a test method to [Jsonrpcmethod] in this class
[Jsonrpcmethod]
private string HelloWorld (String message) {return
' Hello world ' + message;
}
8. Add a Global.asax file and add a static member to it
public class Global:System.Web.HttpApplication {
private static HelloWorldService service = new HelloWorldService () ;
}
9, now can be in our page through the JSON-RPC call method, add a Defualt page, and send a POST request to our JSON-RPC processing, here URL for your project actual URL and port number
<%@ Page language= "C #" autoeventwireup= "true" codebehind= "Defualt.aspx.cs" inherits= "Testjsonrpc.defualt"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
10, click the Testjsonrpc button, return
{"JSONRPC": "2.0", "result": "Hello World Hello World", "Id": "1"}
This indicates that the function call was successful and that the return value was obtained
Article content from http://jsonrpc2.codeplex.com/more about JSONRPC content see here
The demo's C # code download address is attached click here to download