Windows Azure Cloud Service (41) Modifies cloud services IIS managed pipeline mode to 4.0 Classic mode

Source: Internet
Author: User

Windows Azure Platform Family of articles Catalog

This is the author in the previous project encountered problems, do a summary, to make reference for users.

  Under normal circumstances, the cloud service developed by Visual Studio is the IIS managed pipeline mode after it is deployed to the Azure PAAs platform. Sometimes, a customer's Web application requires 4.0 Classic mode. You need to customize the IIS configuration when you start Web role. Let me briefly introduce you here.

1. Add a reference to the project: C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll. The Microsoft.Web.Administration namespace provides a series of operations to manage IIS. For more details, please refer to: Microsoft.Web.Administration Namespace

  

  

2. Modify the Servicedefinition.csdef, add <runtime executioncontext= "elevated"/>, and have permission to modify the IIS configuration

  

3. Modify the public override bool OnStart () method (located in WebRole.cs) to invoke the Microsoft.Web.Administration namespace under the operation set IIS. Refer to the following sample code (the name format for the Cloud Service IIS site is: RoleEnvironment.CurrentRoleInstance.Id + "_web"):

using(Servermanager Servermanager =NewServermanager ()) {          varSiteName = RoleEnvironment.CurrentRoleInstance.Id +"_web"; Trace.Write (string. Format ("Site Name: {0}.", SiteName)); varSiteapplication = Servermanager.sites[roleenvironment.currentroleinstance.id +"_web"].          Applications.first (); Trace.Write (string. Format ("application Pool: {0}.", Siteapplication.applicationpoolname)); varAppPoolName =Siteapplication.applicationpoolname; varAppPool =Servermanager.applicationpools[apppoolname]; if(AppPool! =NULL) {Apppool.managedpipelinemode=Managedpipelinemode.classic;          Servermanager.commitchanges (); }      }

4. Deploying the cloud service, successfully modifying the cloud service IIS managed pipeline mode to 4.0 Classic mode

  

  

Bo-Three Stone Blog (hereinafter referred to as Benbow), at the end of this blog article at the bottom of the right is not noted reproduced, source, provenance of the works (content) are the original, the site for the original content of the copyright reserved, do not arbitrarily reproduced, if the need for a friend can send mail contact me; reproduced original works (content ) must also follow the Creative Commons agreement "attribution-non-commercial use-consistent", be sure to indicate or retain the original source of the article and the information of the blogger (Lei Zhang) in the form of a text link, and be sure to keep in mind that the photograph works on this blog (www.cnblog.com/ Threestone) and other relevant watermark copyright information, otherwise deemed to infringe the original Copyright Act; Benbow declined commercial website reprint. All rights reserved, prohibit illegal and malicious plagiarism which violates the copyright protection Law of the People's Republic of China and related laws and Benbow (legal) statement.

Windows Azure Cloud Service (41) Modifies cloud services IIS managed pipeline mode to 4.0 Classic mode

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.