(实战篇)如何配置web.config
延续之前的,这一期主要看看项目实际运用中的web.config配置
(1)appSettings节点信息配置,保存全局配置信息
<appSettings> <!--首次跳转菜单页面 --> <add key="DefaultToDone" value="已办"/> <add key="DefaultToNew" value="新建"/> <add key="DefaultToSearch" value="查询"/> <add key="Skin" value="DefaultTheme,Green,Blue,Gray,Orange"/> </appSettings>
(2)connectionStrings 数据库连接配置信息
<connectionStrings> <add name="ConnectionPructionKey" connectionString="data source=SERVER2;initial catalog=TEST;integrated security=false;persist security info=True;User ID=sa;Password=@pass;Application Name=group" providerName="System.Data.SqlClient"/> <add name="FileConnectionKey" connectionString="data source=SERVER2;initial catalog=File_TEST;integrated security=false;persist security info=True;User ID=sa;Password=@pass;Application Name=group" providerName="System.Data.SqlClient"/> <add name="LogConnectionKey" connectionString="data source=SERVER2;initial catalog=CLog_TEST;integrated security=false;persist security info=True;User ID=sa;Password=@pass;Application Name=group" providerName="System.Data.SqlClient"/> </connectionStrings>
(3)system.web下httpmoudle和httphandler,附件大小信息的配置
<system.web> <httpHandlers> <add verb="*" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax"/> <add verb="*" path="FWMODALDIALOG.ASPX" type="CIT.OA.CommonUI.HttpHandler.FWHttpHandlerFactory, CIT.OA.CommonUI, Version=1.0.0.0, Culture=neutral"/> <add verb="*" path="FWAJAX.ASPX" type="CIT.OA.CommonUI.HttpHandler.FWHttpHandlerFactory, CIT.OA.CommonUI, Version=1.0.0.0, Culture=neutral"/> <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/> <remove verb="*" path="*.asmx"/> </httpHandlers> <httpModules> <add name="OnlineModule" type="CIT.OA.CommonUI.HttpModule.OnlineModule, CIT.OA.CommonUI, Version=1.0.0.0, Culture=neutral"/> <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </httpModules> <httpRuntime useFullyQualifiedRedirectUrl="false" maxRequestLength="2048000" executionTimeout="3600"></httpRuntime> </system.web>
httphandler和httpmoudle的区别在以后会详细阐述,另外httpruntime可以限定附件上传的大小和超时时间,应该注意!web.config是整个站点的配置文件,里面的配置很复杂,这里列出的只是最常用的几个节点配置,对于一般的项目已经足够。