[Original] cs + html + js + css mode (4): Modify RemoteCallHandler

Source: Internet
Author: User

1. Review:

In the previous article, we gave a detailed introduction to the RemoteCallHandler, including its own internal stream theft and data parsing during access, this allows functions in JavaScript to interact with cs and provides a general understanding of this knowledge.

2. Introduction:

This chapter also introduces RemoteCallHandler. Why do we still introduce this kind of feature? Because we use different browsers in different regions, we will generate redundant characters in our requestHandler, the gzip header file will appear. To solve this header file problem, we will modify the previous code.

3. Modify the RemoteCallHandler class:

 

Original code

/* Obtain the name of the background function to be called */
String methodName = request. Headers ["CallingMethod"];
/* Determine whether the operation type name is null */
If (string. IsNullOrEmpty (typeName) {throw new MissingCallingTypeException ();}
/* Determine whether the called background function name is null */
If (string. IsNullOrEmpty (methodName) {throw new MissingCallingMethodException ();}

 

Modified code

// Main position to be modified: Here, after matching with a regular expression with special characters, take the subsequent character information directly.
Match m = Regex. Match (request. Headers ["CallingMethod"]. Replace (";",""),@"(? <Method> \ w +) 517 MethodEnd ");
If (! M. Success ){
LogUtility. txtLog. writeTraceLog (string. format ("User: {0} \ tAssembly: {1} \ tTypeName: {2} \ tMethodName: {3}", (HttpContext. current. session ["LoginStaff"] as Better. model. MStaffInfo ). staff_id, assembly, typeName, request. headers ["CallingMethod"]);
Throw new MissingCallingMethodException ();
}
String methodName = m. Groups ["method"]. Value;

 

The basic modification is only here, so we are no longer afraid of gzip in requestheader. Next we will talk about the call in js.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.