Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Assigned AppPool resets after completion of Web Deployment Setup when using Custom Actions

Assigned AppPool resets after completion of Web Deployment Setup when using Custom Actions

Scheduled Pinned Locked Moved C#
csharpasp-netdotnetvisual-studiosysadmin
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    www Developerof NET
    wrote on last edited by
    #1

    Hi, I have an Web Application developed in .NET Framework 4.0 and created an deployment setup for the same. The client requirement is to create an custom Apppool and assign it to the virtual directory which is currently installing. To address this issue i created an custom actions project as described in following article. http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx[^] I wrote the following code to create an apppool and assign it to the virtual directory.

    private void CreateAppPoolIIS7()
    {
    using (ServerManager serverManager = new ServerManager())
    {
    string appPoolName = this.Context.Parameters["APPPOOL"];
    ApplicationPool newPool;
    newPool = serverManager.ApplicationPools.FirstOrDefault(x => x.Name == appPoolName);
    if (newPool == null)
    newPool = serverManager.ApplicationPools.Add(appPoolName);
    newPool.ManagedRuntimeVersion = "v4.0";
    newPool.ManagedPipelineMode = ManagedPipelineMode.Classic;
    serverManager.CommitChanges();
    }
    }
    private void AssignIIS7AppPoolToVirDir()
    {
    using (ServerManager serverManager = new ServerManager())
    {
    // Find Default Website
    Microsoft.Web.Administration.Application newApp = null;
    string appPoolName = this.Context.Parameters["APPPOOL"];
    // Get the Root website
    Site site = serverManager.Sites.First(s => s.Id == 1);
    string installpath = this.Context.Parameters["INSTALLDIR"];
    installpath = installpath.TrimEnd('\\');
    //Get the name of the virtual directory
    string virdirname = "/" + installpath.Substring(installpath.LastIndexOf('\\') + 1);

                newApp = site.Applications.FirstOrDefault(x => x.Path == virdirname);
                if (newApp != null)
                {
                    newApp.ApplicationPoolName = appPoolName;
                    serverManager.CommitChanges();
                }
                else
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups