IIS7. Enable/Disable Compression

This commit is contained in:
Sergey 2013-03-06 12:53:22 +02:00
parent c205e3d6e4
commit 181998b145
8 changed files with 144 additions and 10 deletions

View file

@ -56,6 +56,8 @@ namespace WebsitePanel.Providers.Web
private bool enableAnonymousAccess; private bool enableAnonymousAccess;
private bool enableWindowsAuthentication; private bool enableWindowsAuthentication;
private bool enableBasicAuthentication; private bool enableBasicAuthentication;
private bool enableDynamicCompression;
private bool enableStaticCompression;
private string defaultDocs; private string defaultDocs;
private string httpRedirect; private string httpRedirect;
private HttpError[] httpErrors; private HttpError[] httpErrors;
@ -167,6 +169,17 @@ namespace WebsitePanel.Providers.Web
set { this.enableBasicAuthentication = value; } set { this.enableBasicAuthentication = value; }
} }
public bool EnableDynamicCompression
{
get { return this.enableDynamicCompression; }
set { this.enableDynamicCompression = value; }
}
public bool EnableStaticCompression
{
get { return this.enableStaticCompression; }
set { this.enableStaticCompression = value; }
}
public bool AspInstalled public bool AspInstalled
{ {
get { return this.aspInstalled; } get { return this.aspInstalled; }

View file

@ -0,0 +1,53 @@
using System;
using Microsoft.Web.Administration;
using Microsoft.Web.Management.Server;
using WebsitePanel.Providers.Web.Iis.Common;
namespace WebsitePanel.Providers.Web.Compression
{
internal static class CompressionGlobals
{
public const int DynamicCompression = 1;
public const int StaticCompression = 2;
}
internal sealed class CompressionModuleService : ConfigurationModuleService
{
public const string DynamicCompression = "doDynamicCompression";
public const string StaticCompression = "doStaticCompression";
public PropertyBag GetSettings(ServerManager srvman, string siteId)
{
var config = srvman.GetApplicationHostConfiguration();
//
var section = config.GetSection(Constants.CompressionSection, siteId);
//
PropertyBag bag = new PropertyBag();
//
bag[CompressionGlobals.DynamicCompression] = Convert.ToBoolean(section.GetAttributeValue(DynamicCompression));
bag[CompressionGlobals.StaticCompression] = Convert.ToBoolean(section.GetAttributeValue(StaticCompression));
//
return bag;
}
public void SetSettings(string virtualPath, bool doDynamicCompression, bool doStaticCompression)
{
using (var srvman = GetServerManager())
{
var config = srvman.GetApplicationHostConfiguration();
//
var section = config.GetSection(Constants.CompressionSection, virtualPath);
//
section.SetAttributeValue(DynamicCompression, doDynamicCompression);
section.SetAttributeValue(StaticCompression, doStaticCompression);
//
srvman.CommitChanges();
}
}
}
}

View file

@ -38,6 +38,7 @@ using WebsitePanel.Providers.HostedSolution;
using WebsitePanel.Providers.OS; using WebsitePanel.Providers.OS;
using WebsitePanel.Providers.ResultObjects; using WebsitePanel.Providers.ResultObjects;
using WebsitePanel.Providers.Utils; using WebsitePanel.Providers.Utils;
using WebsitePanel.Providers.Web.Compression;
using WebsitePanel.Providers.Web.Handlers; using WebsitePanel.Providers.Web.Handlers;
using WebsitePanel.Providers.Web.HttpRedirect; using WebsitePanel.Providers.Web.HttpRedirect;
using WebsitePanel.Providers.Web.Iis.Authentication; using WebsitePanel.Providers.Web.Iis.Authentication;
@ -78,6 +79,7 @@ namespace WebsitePanel.Providers.Web
public const string AnonymousAuthenticationSection = "system.webServer/security/authentication/anonymousAuthentication"; public const string AnonymousAuthenticationSection = "system.webServer/security/authentication/anonymousAuthentication";
public const string BasicAuthenticationSection = "system.webServer/security/authentication/basicAuthentication"; public const string BasicAuthenticationSection = "system.webServer/security/authentication/basicAuthentication";
public const string WindowsAuthenticationSection = "system.webServer/security/authentication/windowsAuthentication"; public const string WindowsAuthenticationSection = "system.webServer/security/authentication/windowsAuthentication";
public const string CompressionSection = "system.webServer/urlCompression";
public const string StaticContentSection = "system.webServer/staticContent"; public const string StaticContentSection = "system.webServer/staticContent";
public const string ModulesSection = "system.webServer/modules"; public const string ModulesSection = "system.webServer/modules";
public const string IsapiCgiRestrictionSection = "system.webServer/security/isapiCgiRestriction"; public const string IsapiCgiRestrictionSection = "system.webServer/security/isapiCgiRestriction";
@ -347,6 +349,7 @@ namespace WebsitePanel.Providers.Web
private AnonymAuthModuleService anonymAuthSvc; private AnonymAuthModuleService anonymAuthSvc;
private WindowsAuthModuleService winAuthSvc; private WindowsAuthModuleService winAuthSvc;
private BasicAuthModuleService basicAuthSvc; private BasicAuthModuleService basicAuthSvc;
private CompressionModuleService comprSvc;
private DefaultDocsModuleService defaultDocSvc; private DefaultDocsModuleService defaultDocSvc;
private CustomHttpErrorsModuleService customErrorsSvc; private CustomHttpErrorsModuleService customErrorsSvc;
private CustomHttpHeadersModuleService customHeadersSvc; private CustomHttpHeadersModuleService customHeadersSvc;
@ -519,6 +522,7 @@ namespace WebsitePanel.Providers.Web
winAuthSvc = new WindowsAuthModuleService(); winAuthSvc = new WindowsAuthModuleService();
anonymAuthSvc = new AnonymAuthModuleService(); anonymAuthSvc = new AnonymAuthModuleService();
basicAuthSvc = new BasicAuthModuleService(); basicAuthSvc = new BasicAuthModuleService();
comprSvc = new CompressionModuleService();
defaultDocSvc = new DefaultDocsModuleService(); defaultDocSvc = new DefaultDocsModuleService();
classicAspSvc = new ClassicAspModuleService(); classicAspSvc = new ClassicAspModuleService();
httpRedirectSvc = new HttpRedirectModuleService(); httpRedirectSvc = new HttpRedirectModuleService();
@ -623,6 +627,8 @@ namespace WebsitePanel.Providers.Web
virtualDir.AnonymousUserPassword = (string)bag[AuthenticationGlobals.AnonymousAuthenticationPassword]; virtualDir.AnonymousUserPassword = (string)bag[AuthenticationGlobals.AnonymousAuthenticationPassword];
virtualDir.EnableAnonymousAccess = (bool)bag[AuthenticationGlobals.Enabled]; virtualDir.EnableAnonymousAccess = (bool)bag[AuthenticationGlobals.Enabled];
// load windows auth // load windows auth
bag = winAuthSvc.GetAuthenticationSettings(srvman, virtualDir.FullQualifiedPath); bag = winAuthSvc.GetAuthenticationSettings(srvman, virtualDir.FullQualifiedPath);
virtualDir.EnableWindowsAuthentication = (bool)bag[AuthenticationGlobals.Enabled]; virtualDir.EnableWindowsAuthentication = (bool)bag[AuthenticationGlobals.Enabled];
@ -636,10 +642,17 @@ namespace WebsitePanel.Providers.Web
bag = classicAspSvc.GetClassicAspSettings(srvman, virtualDir.FullQualifiedPath); bag = classicAspSvc.GetClassicAspSettings(srvman, virtualDir.FullQualifiedPath);
virtualDir.EnableParentPaths = (bool)bag[ClassicAspGlobals.EnableParentPaths]; virtualDir.EnableParentPaths = (bool)bag[ClassicAspGlobals.EnableParentPaths];
// //
//gzip
bag = comprSvc.GetSettings(srvman, virtualDir.FullQualifiedPath);
virtualDir.EnableDynamicCompression = (bool)bag[CompressionGlobals.DynamicCompression];
virtualDir.EnableStaticCompression = (bool)bag[CompressionGlobals.StaticCompression];
virtualDir.IIs7 = true; virtualDir.IIs7 = true;
} }
private void FillIISObjectFromVirtualDirectory(WebVirtualDirectory virtualDir)
private void FillIISObjectFromVirtualDirectory(WebVirtualDirectory virtualDir)
{ {
dirBrowseSvc.SetDirectoryBrowseEnabled(virtualDir.FullQualifiedPath, virtualDir.EnableDirectoryBrowsing); dirBrowseSvc.SetDirectoryBrowseEnabled(virtualDir.FullQualifiedPath, virtualDir.EnableDirectoryBrowsing);
// //
@ -648,6 +661,8 @@ namespace WebsitePanel.Providers.Web
winAuthSvc.SetEnabled(virtualDir.FullQualifiedPath, virtualDir.EnableWindowsAuthentication); winAuthSvc.SetEnabled(virtualDir.FullQualifiedPath, virtualDir.EnableWindowsAuthentication);
// //
basicAuthSvc.SetAuthenticationSettings(virtualDir); basicAuthSvc.SetAuthenticationSettings(virtualDir);
//
comprSvc.SetSettings(virtualDir.FullQualifiedPath, virtualDir.EnableDynamicCompression, virtualDir.EnableStaticCompression);
// //
defaultDocSvc.SetDefaultDocumentSettings(virtualDir.FullQualifiedPath, virtualDir.DefaultDocs); defaultDocSvc.SetDefaultDocumentSettings(virtualDir.FullQualifiedPath, virtualDir.DefaultDocs);
// //

View file

@ -91,6 +91,7 @@
<Compile Include="Common\FastCgiApplicationCollection.cs" /> <Compile Include="Common\FastCgiApplicationCollection.cs" />
<Compile Include="Common\FastCgiSection.cs" /> <Compile Include="Common\FastCgiSection.cs" />
<Compile Include="Common\HttpErrorResponseMode.cs" /> <Compile Include="Common\HttpErrorResponseMode.cs" />
<Compile Include="Compression\CompressionModuleService.cs" />
<Compile Include="DefaultDocuments\DefaultDocumentModuleService.cs" /> <Compile Include="DefaultDocuments\DefaultDocumentModuleService.cs" />
<Compile Include="Delegation\DelegationRulesModuleService.cs" /> <Compile Include="Delegation\DelegationRulesModuleService.cs" />
<Compile Include="DirectoryBrowse\DirectoryBrowseGlobals.cs" /> <Compile Include="DirectoryBrowse\DirectoryBrowseGlobals.cs" />

View file

@ -129,6 +129,12 @@
<data name="chkAuthBasic.Text" xml:space="preserve"> <data name="chkAuthBasic.Text" xml:space="preserve">
<value>Enable Basic Authentication</value> <value>Enable Basic Authentication</value>
</data> </data>
<data name="chkDynamicCompression.Text" xml:space="preserve">
<value>Enable Dynamic Compression</value>
</data>
<data name="chkStaticCompression.Text" xml:space="preserve">
<value>Enable Static Compression</value>
</data>
<data name="chkAuthWindows.Text" xml:space="preserve"> <data name="chkAuthWindows.Text" xml:space="preserve">
<value>Enable Integrated Windows Authentication</value> <value>Enable Integrated Windows Authentication</value>
</data> </data>
@ -159,6 +165,9 @@
<data name="lblAuthentication.Text" xml:space="preserve"> <data name="lblAuthentication.Text" xml:space="preserve">
<value>Authentication:</value> <value>Authentication:</value>
</data> </data>
<data name="lblCompression.Text" xml:space="preserve">
<value>Compression:</value>
</data>
<data name="lblDefaultDocuments.Text" xml:space="preserve"> <data name="lblDefaultDocuments.Text" xml:space="preserve">
<value>Default Documents:</value> <value>Default Documents:</value>
</data> </data>

View file

@ -52,6 +52,7 @@
<td><asp:checkbox id="chkDedicatedPool" meta:resourcekey="chkDedicatedPool" Text="Dedicated Application Pool" Runat="server"></asp:checkbox></td> <td><asp:checkbox id="chkDedicatedPool" meta:resourcekey="chkDedicatedPool" Text="Dedicated Application Pool" Runat="server"></asp:checkbox></td>
</tr> </tr>
</table> </table>
<asp:PlaceHolder runat="server" id="pnlCustomAuth"> <asp:PlaceHolder runat="server" id="pnlCustomAuth">
<br /> <br />
<table class="Normal" cellSpacing="0" cellPadding="3"> <table class="Normal" cellSpacing="0" cellPadding="3">
@ -69,8 +70,25 @@
<tr> <tr>
<td nowrap><asp:checkbox id="chkAuthBasic" meta:resourcekey="chkAuthBasic" Text="Basic authentication" Runat="server"></asp:checkbox></td> <td nowrap><asp:checkbox id="chkAuthBasic" meta:resourcekey="chkAuthBasic" Text="Basic authentication" Runat="server"></asp:checkbox></td>
</tr> </tr>
</table>
</table>
</asp:PlaceHolder> </asp:PlaceHolder>
<table class="Normal" cellSpacing="0" cellPadding="3">
<tr>
<td class="NormalBold">
<asp:Label ID="lblCompression" runat="server" meta:resourcekey="lblCompression" Text="Compression:"></asp:Label>
</td>
</tr>
<tr>
<td nowrap><asp:checkbox id="chkDynamicCompression" meta:resourcekey="chkDynamicCompression" Text="Enable dynamic compression" Runat="server"></asp:checkbox></td>
</tr>
<tr>
<td nowrap><asp:checkbox id="chkStaticCompression" meta:resourcekey="chkStaticCompression" Text="Enable static compression" Runat="server"></asp:checkbox></td>
</tr>
</table>
</td> </td>
<td width="30" nowrap></td> <td width="30" nowrap></td>
<td valign="top"> <td valign="top">

View file

@ -81,6 +81,8 @@ namespace WebsitePanel.Portal
chkAuthAnonymous.Checked = item.EnableAnonymousAccess; chkAuthAnonymous.Checked = item.EnableAnonymousAccess;
chkAuthWindows.Checked = item.EnableWindowsAuthentication; chkAuthWindows.Checked = item.EnableWindowsAuthentication;
chkAuthBasic.Checked = item.EnableBasicAuthentication; chkAuthBasic.Checked = item.EnableBasicAuthentication;
chkDynamicCompression.Checked = item.EnableDynamicCompression;
chkStaticCompression.Checked = item.EnableStaticCompression;
// default documents // default documents
txtDefaultDocs.Text = String.Join("\n", item.DefaultDocs.Split(',', ';')); txtDefaultDocs.Text = String.Join("\n", item.DefaultDocs.Split(',', ';'));
@ -131,6 +133,9 @@ namespace WebsitePanel.Portal
item.EnableAnonymousAccess = chkAuthAnonymous.Checked; item.EnableAnonymousAccess = chkAuthAnonymous.Checked;
item.EnableWindowsAuthentication = chkAuthWindows.Checked; item.EnableWindowsAuthentication = chkAuthWindows.Checked;
item.EnableBasicAuthentication = chkAuthBasic.Checked; item.EnableBasicAuthentication = chkAuthBasic.Checked;
item.EnableDynamicCompression = chkDynamicCompression.Checked;
item.EnableStaticCompression = chkStaticCompression.Checked;
// default documents // default documents
item.DefaultDocs = String.Join(",", Utils.ParseDelimitedString(txtDefaultDocs.Text, '\n', '\r', ';', ',')); item.DefaultDocs = String.Join(",", Utils.ParseDelimitedString(txtDefaultDocs.Text, '\n', '\r', ';', ','));

View file

@ -1,22 +1,15 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:2.0.50727.312
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace WebsitePanel.Portal { namespace WebsitePanel.Portal {
/// <summary>
/// WebSitesHomeFolderControl class.
/// </summary>
/// <remarks>
/// Auto-generated class.
/// </remarks>
public partial class WebSitesHomeFolderControl { public partial class WebSitesHomeFolderControl {
/// <summary> /// <summary>
@ -163,6 +156,33 @@ namespace WebsitePanel.Portal {
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.CheckBox chkAuthBasic; protected global::System.Web.UI.WebControls.CheckBox chkAuthBasic;
/// <summary>
/// lblCompression control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblCompression;
/// <summary>
/// chkDynamicCompression control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.CheckBox chkDynamicCompression;
/// <summary>
/// chkStaticCompression control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.CheckBox chkStaticCompression;
/// <summary> /// <summary>
/// pnlDefaultDocuments control. /// pnlDefaultDocuments control.
/// </summary> /// </summary>