IIS7. Enable/Disable Compression
This commit is contained in:
parent
c205e3d6e4
commit
181998b145
8 changed files with 144 additions and 10 deletions
|
@ -56,6 +56,8 @@ namespace WebsitePanel.Providers.Web
|
|||
private bool enableAnonymousAccess;
|
||||
private bool enableWindowsAuthentication;
|
||||
private bool enableBasicAuthentication;
|
||||
private bool enableDynamicCompression;
|
||||
private bool enableStaticCompression;
|
||||
private string defaultDocs;
|
||||
private string httpRedirect;
|
||||
private HttpError[] httpErrors;
|
||||
|
@ -167,6 +169,17 @@ namespace WebsitePanel.Providers.Web
|
|||
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
|
||||
{
|
||||
get { return this.aspInstalled; }
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ using WebsitePanel.Providers.HostedSolution;
|
|||
using WebsitePanel.Providers.OS;
|
||||
using WebsitePanel.Providers.ResultObjects;
|
||||
using WebsitePanel.Providers.Utils;
|
||||
using WebsitePanel.Providers.Web.Compression;
|
||||
using WebsitePanel.Providers.Web.Handlers;
|
||||
using WebsitePanel.Providers.Web.HttpRedirect;
|
||||
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 BasicAuthenticationSection = "system.webServer/security/authentication/basicAuthentication";
|
||||
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 ModulesSection = "system.webServer/modules";
|
||||
public const string IsapiCgiRestrictionSection = "system.webServer/security/isapiCgiRestriction";
|
||||
|
@ -347,6 +349,7 @@ namespace WebsitePanel.Providers.Web
|
|||
private AnonymAuthModuleService anonymAuthSvc;
|
||||
private WindowsAuthModuleService winAuthSvc;
|
||||
private BasicAuthModuleService basicAuthSvc;
|
||||
private CompressionModuleService comprSvc;
|
||||
private DefaultDocsModuleService defaultDocSvc;
|
||||
private CustomHttpErrorsModuleService customErrorsSvc;
|
||||
private CustomHttpHeadersModuleService customHeadersSvc;
|
||||
|
@ -519,6 +522,7 @@ namespace WebsitePanel.Providers.Web
|
|||
winAuthSvc = new WindowsAuthModuleService();
|
||||
anonymAuthSvc = new AnonymAuthModuleService();
|
||||
basicAuthSvc = new BasicAuthModuleService();
|
||||
comprSvc = new CompressionModuleService();
|
||||
defaultDocSvc = new DefaultDocsModuleService();
|
||||
classicAspSvc = new ClassicAspModuleService();
|
||||
httpRedirectSvc = new HttpRedirectModuleService();
|
||||
|
@ -623,6 +627,8 @@ namespace WebsitePanel.Providers.Web
|
|||
virtualDir.AnonymousUserPassword = (string)bag[AuthenticationGlobals.AnonymousAuthenticationPassword];
|
||||
virtualDir.EnableAnonymousAccess = (bool)bag[AuthenticationGlobals.Enabled];
|
||||
|
||||
|
||||
|
||||
// load windows auth
|
||||
bag = winAuthSvc.GetAuthenticationSettings(srvman, virtualDir.FullQualifiedPath);
|
||||
virtualDir.EnableWindowsAuthentication = (bool)bag[AuthenticationGlobals.Enabled];
|
||||
|
@ -636,10 +642,17 @@ namespace WebsitePanel.Providers.Web
|
|||
bag = classicAspSvc.GetClassicAspSettings(srvman, virtualDir.FullQualifiedPath);
|
||||
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;
|
||||
}
|
||||
|
||||
private void FillIISObjectFromVirtualDirectory(WebVirtualDirectory virtualDir)
|
||||
|
||||
private void FillIISObjectFromVirtualDirectory(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
dirBrowseSvc.SetDirectoryBrowseEnabled(virtualDir.FullQualifiedPath, virtualDir.EnableDirectoryBrowsing);
|
||||
//
|
||||
|
@ -648,6 +661,8 @@ namespace WebsitePanel.Providers.Web
|
|||
winAuthSvc.SetEnabled(virtualDir.FullQualifiedPath, virtualDir.EnableWindowsAuthentication);
|
||||
//
|
||||
basicAuthSvc.SetAuthenticationSettings(virtualDir);
|
||||
//
|
||||
comprSvc.SetSettings(virtualDir.FullQualifiedPath, virtualDir.EnableDynamicCompression, virtualDir.EnableStaticCompression);
|
||||
//
|
||||
defaultDocSvc.SetDefaultDocumentSettings(virtualDir.FullQualifiedPath, virtualDir.DefaultDocs);
|
||||
//
|
||||
|
|
|
@ -91,6 +91,7 @@
|
|||
<Compile Include="Common\FastCgiApplicationCollection.cs" />
|
||||
<Compile Include="Common\FastCgiSection.cs" />
|
||||
<Compile Include="Common\HttpErrorResponseMode.cs" />
|
||||
<Compile Include="Compression\CompressionModuleService.cs" />
|
||||
<Compile Include="DefaultDocuments\DefaultDocumentModuleService.cs" />
|
||||
<Compile Include="Delegation\DelegationRulesModuleService.cs" />
|
||||
<Compile Include="DirectoryBrowse\DirectoryBrowseGlobals.cs" />
|
||||
|
|
|
@ -129,6 +129,12 @@
|
|||
<data name="chkAuthBasic.Text" xml:space="preserve">
|
||||
<value>Enable Basic Authentication</value>
|
||||
</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">
|
||||
<value>Enable Integrated Windows Authentication</value>
|
||||
</data>
|
||||
|
@ -159,6 +165,9 @@
|
|||
<data name="lblAuthentication.Text" xml:space="preserve">
|
||||
<value>Authentication:</value>
|
||||
</data>
|
||||
<data name="lblCompression.Text" xml:space="preserve">
|
||||
<value>Compression:</value>
|
||||
</data>
|
||||
<data name="lblDefaultDocuments.Text" xml:space="preserve">
|
||||
<value>Default Documents:</value>
|
||||
</data>
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<td><asp:checkbox id="chkDedicatedPool" meta:resourcekey="chkDedicatedPool" Text="Dedicated Application Pool" Runat="server"></asp:checkbox></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<asp:PlaceHolder runat="server" id="pnlCustomAuth">
|
||||
<br />
|
||||
<table class="Normal" cellSpacing="0" cellPadding="3">
|
||||
|
@ -69,8 +70,25 @@
|
|||
<tr>
|
||||
<td nowrap><asp:checkbox id="chkAuthBasic" meta:resourcekey="chkAuthBasic" Text="Basic authentication" Runat="server"></asp:checkbox></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</table>
|
||||
</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 width="30" nowrap></td>
|
||||
<td valign="top">
|
||||
|
|
|
@ -81,6 +81,8 @@ namespace WebsitePanel.Portal
|
|||
chkAuthAnonymous.Checked = item.EnableAnonymousAccess;
|
||||
chkAuthWindows.Checked = item.EnableWindowsAuthentication;
|
||||
chkAuthBasic.Checked = item.EnableBasicAuthentication;
|
||||
chkDynamicCompression.Checked = item.EnableDynamicCompression;
|
||||
chkStaticCompression.Checked = item.EnableStaticCompression;
|
||||
|
||||
// default documents
|
||||
txtDefaultDocs.Text = String.Join("\n", item.DefaultDocs.Split(',', ';'));
|
||||
|
@ -131,6 +133,9 @@ namespace WebsitePanel.Portal
|
|||
item.EnableAnonymousAccess = chkAuthAnonymous.Checked;
|
||||
item.EnableWindowsAuthentication = chkAuthWindows.Checked;
|
||||
item.EnableBasicAuthentication = chkAuthBasic.Checked;
|
||||
item.EnableDynamicCompression = chkDynamicCompression.Checked;
|
||||
item.EnableStaticCompression = chkStaticCompression.Checked;
|
||||
|
||||
|
||||
// default documents
|
||||
item.DefaultDocs = String.Join(",", Utils.ParseDelimitedString(txtDefaultDocs.Text, '\n', '\r', ';', ','));
|
||||
|
|
|
@ -1,22 +1,15 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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
|
||||
// the code is regenerated.
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WebsitePanel.Portal {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// WebSitesHomeFolderControl class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated class.
|
||||
/// </remarks>
|
||||
public partial class WebSitesHomeFolderControl {
|
||||
|
||||
/// <summary>
|
||||
|
@ -163,6 +156,33 @@ namespace WebsitePanel.Portal {
|
|||
/// </remarks>
|
||||
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>
|
||||
/// pnlDefaultDocuments control.
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue