配置声明节
复制代码代码如下:
<configSections>
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="urlrewritingnet" requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter" />
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
<sectionGroup name="powereasy.web" type="PowerEasy.Web.Configuration.ComponentsSectionGroup, PowerEasy.Web">
<section name="queryStrings" type="PowerEasy.Web.Configuration.QueryStringsSection, PowerEasy.Web" />
<section name="security" type="PowerEasy.Web.Configuration.SecuritySection, PowerEasy.Web" />
</sectionGroup>
</configSections>
这个节定义了,web.config文件中将要用到具体配置节点的名称,处理程序等.
从这里可以看出,siteFactory里采用.net 企业应用程序块(enterpriseLibrary),里的数据访问块等.
urlrewritingnet,是用来进行地址重写的,接着是asp.net ajax 配置节声明,最后有个sectionGroup声明,里面的配置节声明分别是,siteFactory页面访问控制(安全),页面访问参数等(.aspx?xxx 问号后面的xxx部分)
声明节后就是具体的数据配置节点了
复制代码代码如下:
<connectionStrings configSource="Config\ConnectionStrings.config" />
这个就是数据库连接字符串的配置,具体的数据在config目录下的ConnectionStrings.config文件里,打开这个文件可以看到如下内容
复制代码代码如下:
<!--指定数据库连接字符串(名称/值对的形式)的集合。-->
<connectionStrings>
<add name="Connection String" connectionString="server=.;database=SiteFactory;uid=PowerEasy;pwd=123456"
providerName="System.Data.SqlClient" />
</connectionStrings>
这里就是大家熟悉的数据库连接字符串内容了,根据需要你可以将connectionString="xxx"里面的xxx内容改成你当前数据库连接配置.
复制代码代码如下:
<httpHandlers>
<remove verb="*" path="*.asmx" />
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
<add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add verb="*" path="*.jpg" type="PowerEasy.Web.NoLeechImageHandler, PowerEasy.Web" />
<add verb="*" path="*.gif" type="PowerEasy.Web.NoLeechImageHandler, PowerEasy.Web" />
<add verb="*" path="*.png" type="PowerEasy.Web.NoLeechImageHandler, PowerEasy.Web" />
</httpHandlers>
这里是处理程序配置,前面几个是asp.net ajax的,后面3个是siteFactory用来防止图片盗连用的,具体的实现思路是,判断图片文件请求的标头中的Referrer是否是本网站的地址,如果你的网站不存在防盗连需求(向来多是你盗用别人的"_-!)你可以用
复制代码代码如下:
<!--
<add verb="*" path="*.jpg" type="PowerEasy.Web.NoLeechImageHandler, PowerEasy.Web" />
<add verb="*" path="*.gif" type="PowerEasy.Web.NoLeechImageHandler, PowerEasy.Web" />
<add verb="*" path="*.png" type="PowerEasy.Web.NoLeechImageHandler, PowerEasy.Web" />
-->标价将3个注释掉
<httpModules>
<add name="RefreshModule" type="PowerEasy.Web.HttpModule.RefreshModule, PowerEasy.Web" />
<add name="CommonModule" type="PowerEasy.Web.HttpModule.CommonModule, PowerEasy.Web" />
<add name="IPLockModule" type="PowerEasy.Web.HttpModule.IPLockModule, PowerEasy.Web" />
<add name="ExceptionModule" type="PowerEasy.Web.HttpModule.ExceptionModule, PowerEasy.Web" />
<add name="SecurityModule" type="PowerEasy.Web.HttpModule.SecurityModule, PowerEasy.Web" />
<add name="QueryStringModule" type="PowerEasy.Web.HttpModule.QueryStringModule, PowerEasy.Web" />
<add name="HttpUploadModule" type="PowerEasy.Controls.ExtendedUploadFile.HttpUploadModule, PowerEasy.Controls" />
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
</httpModules>
是处理模块,除了ScriptModule是asp.net ajax指定的处理模块外,其他的多是siteFactory的,你可以根据情况屏蔽掉一些
比方RefresModule是防刷新用的,IPLokeModule是用来屏蔽IP的....
另外注意在web.config后面有个<system.webServer>...</system.webServer> 节,这个是IIS7.0中新增加的,性质跟上面的<httpHandlers><httpModules>一样的.
复制代码代码如下:
<!--为当前应用程序配置会话状态设置。-->
<sessionState mode="InProc" timeout="20">
表示用户会话保存在进程内20表示是失效时间,不过sessionState实际的失效时间取决于服务器的负担.
<urlMappings enabled="true">
<clear />
<add url="~/Index.aspx" mappedUrl="~/Default.aspx" />
<add url="~/User/Index.aspx" mappedUrl="~/User/Default.aspx" />
</urlMappings>
urlMappings 是.net2.0自带的地址重写机智,不支持正则表达式,但是一般的应用多可以满足,并且很方便
<webParts>
<personalization defaultProvider="WebPartPersonalizationProvider">
<providers>
<add name="WebPartPersonalizationProvider" type="PowerEasy.UserManage.WebPartProvider, PowerEasy.UserManage" />
</providers>
</personalization>
</webParts>
这一段是SiteFactory提供的WebParts个性数据保存的配置,另外asp.net2.0也提供sql实现的一个提供程序,你可以使用aspnet_regsql来实现.
复制代码代码如下:
<urlrewritingnet configSource="Config\UrlRewriteSettings.config" />
<powereasy.web>
<security configSource="Config\Security.config" />
<!--指定页面传递参数的集合。-->
<queryStrings configSource="Config\QueryStrings.config" />
</powereasy.web>
这几对的数据多是在其指顶的文件里,你可以去config目录下查看,
例外config目录下有CreateCollectionWork.config,CreateHtmlWork.config是数据采集,与将静态页生成用的,目的是用来在进程间交换信息的.Site.config等是具体数据文件,通过类序列化保存的,比方防刷新队列的长度就保存在这里文件里,你可以通过后台配置修改,也可以在这里直接修改.