Lightweight Web data service framework: kingsoc. Web. webcall 1. Introduction
(1) It is a lightweight and convenient Web Data Service Framework. (2) automatically generate a client JS call script for any page/handler/class on the server (including dynamically compiled classes, such as the CS class in aspx and app_code). (3) provide data in a way similar to WebService URL, for example, handler1.ashx \ gettime (4) returns rich formats (XML, JSON, text, image ), the client can specify the data format returned by the server (5) with the cache mechanism ps. this component can effectively reduce the complexity of the data service-based system. A set of CS code can be used by the server or published to the client for calling, effectively reducing the amount of code and facilitating maintenance. In fact, it is a bit similar to webapi, but it is not deliberately encapsulated into a rest method. This module focuses on method calls. 2. Functions
Method ing
- View the JS file mapped to the client by the app_code class
- View JS files mapped to the client by the aspx class
- View the JS file mapped by the ashx class to the client
- View the JS file mapped from the aspx file to the client
- View the JS file mapped from the ashx file to the client
Method call
- Call the app_code class method (using JS function calls mapped to the client)
- Call the app_code class method (use jquery to manually write the call code)
- Call the aspx Class Method
Output Format
- Server return format: Text
- Server return format: JSON
- Server return format: Image
- The client specifies the server method output format: XML
- The output format of the method specified by the client on the server is JSON.
- The client specifies the server method output format: imagebase64
3. Use
(1) Add a reference to kingsoc. Web. webcall. dll (2) create any class. Use the [webcall] feature to tag the server code such as using system and using kingsoc. web. webcall; namespace app {public class democlass {[webcall (type = responsedatatype. text, description = "demonstrate custom serialization to HTML"), cacheduration = 30] Public String helloworld (string info) {system. threading. thread. sleep (200); Return "Hello World" + info ;}}( 2) Register httphandler:
4. Download
Example project: testwebcall