Compatibility between the WCF Service and ASMX service in ASP. NET

Source: Internet
Author: User

According to the previous operation, when a new WCF Service is created for the asp.net AJAX program, the AspNetCompatibilityRequirements attribute is used before the service class by default. Now let's make a brief analysis.

Analysis of WCF and ASMX services in ASP. NET:

 
 
  1. [ServiceContract]     
  2. [AspNetCompatibilityRequirements(     
  3. RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]     
  4. public class TimeService     
  5. {     
  6. ……     
  7. }    

Although it can be designed for independent transmission, when applied to an asp.net AJAX application environment, the WCF Service can actually work in a way very similar to the ASMX service. With this AspNetCompatibilityRequirements attribute, We can instruct WCF to use the same model as the ASMX service for work. In practice, this setting indicates that when a WCF Service is activated, the declared endpoints will be checked at runtime and the Web HTTP binding model will be used to ensure that all of them are used.

The good compatibility with the ASMX service makes it possible to access asp.net objects such as HttpContext objects and other internal asp.net objects in the WCF Service.

Note that the compatibility between the WCF Service and the ASMX service in ASP. NET must be achieved at least two points. First, in the configuration file web. config, you need to make declaration definitions similar to the following:

 
 
  1. < system.serviceModel>    
  2. :     
  3. < serviceHostingEnvironment aspNetCompatibilityEnabled="true" />    
  4. < /system.serviceModel>   

Second, the developer needs to explicitly select a compatibility mode for the given WCF Service, which is completed by using the service AspNetCompatibilityRequirements attribute.

The service request in the asp.net AJAX application must be configured on the server. In conclusion, there are currently two main software technologies in asp.net applications that can be used to build services: ASMX Web Services and WCF services. Among them, the WCF Service already includes the ASMX Web service. However, it must be clear that AJAX communication requires the use of JSON data strings for data transmission back and forth between the client and the server. In the era of asp.net AJAX extension 1.0 or in asp.net 3.5, adjusting the runtime of asp.net makes it easier for ASMX Web services to support JSON. However, for a richer range of WCF services, it is slightly more complex to implement JSON data format transmission. This is why the AJAX backend service can be built using WCF only in asp.net 3.5. The compatibility between the WCF Service and the ASMX service in ASP. NET is described above.

  1. Principles and Applications of ASP. NET1.1 Verification Code Generation
  2. Static File Processing: ASP. NET1.1 and ASP. NET2.0 are different.
  3. Run the windows program (ASP. NET1.1) in ASP. NET)
  4. Modify the template class for asp. net1.1 Development
  5. Connect Oracle9i with ASP. NET (ASP. NET1.1)

Related Article

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.