190 likes | 295 Views
Web .Config. Ahmed_Moosa83@yahoo.com. Ahmed Moosa ASP.Net Instructor. Download Slides. www.Ahmedmoosa.wordpress.com. Web .Config. Web .config in Xml File . IntelliSense Make It Better Can Configure All Web Site Pages There are Two File Machine .config Web. Config
E N D
Web .Config Ahmed_Moosa83@yahoo.com Ahmed Moosa ASP.Net Instructor
Download Slides www.Ahmedmoosa.wordpress.com
Web .Config • Web .config in Xml File . • IntelliSense Make It Better • Can Configure All Web Site Pages • There are Two File • Machine .config • Web. Config • Can Find Them : (C:\WINDOWS\Microsoft.NET\Framework\[version]\CONFIG ) • Have Default Setting also in • web.config.default • Machine.config.default
Must • Enter All Settings Between • <Configuration > …. </Configuration > • Case Sensitive Declaration • camelCase All Properties • Define Namespaces When Programmatically • System .Configuration • System.Web.Configuration • Define Your Setting Between it’s Category • <System. Web >……</System. Web> • <System. Net >…….</System. Net >
Some Elements • configure Page directive Setting s : • <pages> • Configure Connection String : • <connectionStrings > • Configure Application Setting s: • <appSettings> • Configure Error Pages : • <customError> • Configure Membership • <membership>
<Pages> • You Can Set • a lot Of Properties For Example <pages masterPageFile ="MyMasterPage.master“ theme="myTheme“ > </pages> • Set Namespace <pages > <namespaces > <add namespace="System.Data.SqlClient"/> </namespaces> </pages> • Add Controls Like Ajax Controls <controls >….<controls>
<Location> • <Pages> ..</Pages> To All Pages • <Location>…</Location> as You Specify • Page - Folder - Subfolder (as you Like ) . • Example:- Set Master Page To Admin Folder only <location path ="Admin"> <system.web> <pages masterPageFile="AdminMasterPage.master" /> </system.web> </location>
<customError> • Can Show friendly Error • Set Default Redirect Page URL • Show Page by Error Code • Like this : <system.web> <customErrors mode ="On" defaultRedirect ="defaultErrorPage.aspx" > <error statusCode ="404" redirect ="NotFound.aspx"/> <error statusCode ="500" redirect ="CallSupport.aspx"/> <error statusCode ="403" redirect ="Forbidden.aspx"/> </customErrors> </system.web> • There are A lot Of Details about Will be in My Blog .
<Globalization> • Set Multilanguage Site • Working With Resource File (resource.resx ) • UiCulture (User interface ) Will Change • Like This : <system.web> <globalization culture ="auto:ar-eg" uiCulture ="auto" /> </system.web> • Above I set Default Culture To Arabic Egypt • User Interface Will Change as I set In My Internet Option Explorer Sequentially .
<trace> • It ‘s a page I Call It Manually in Address Bar • comes With Extension .axd ( trace.axd ) • Show Number of request That Users Call • Can Follow all Request in Web Site By Details • Like This :- <system.web> <trace enabled="true" traceMode="SortByTime" mostRecent="true" requestLimit="10" pageOutput="false" localOnly ="true" /> </system.web>
Trace Page http://localhost:8080//MyWebsite/trace.xd
<ConnectionStrings> • Define Data Source , Server and Security • In My Visual Web Developer Express Edition It‘s Like This : <connectionStrings> <add name="MyConnectionString“ connectionString ="Data Source =.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\MyDataBaseFile.mdf; Integrated Security=True;User Instance=True"/> </connectionStrings> • It Is Simple ( Set and Forget ) • Call it any Page You Want .
<appSetttings> • Define Global Variable using Key and Value. Example: <appSettings> <add key ="MyVariable" value ="SomeValue"/> </appSettings> • Also Can define more than one variable . - Note :Can Store Connection Strings
<mailSettings> • Set Mail Settings (Host info – sender info-…) • Mail Settings is under System.Net Category • Like :- <system.net> <mailSettings> <smtp from="admin@mysite.com" > <network host="smtp.mysite.com" userName ="admin" password =“*********" /> </smtp> </mailSettings> </system.net>
<httpRuntime> • Set Http Runtime Settings • Use it When Upload Large Files <system.web> <httpRuntime maxRequestLength ="1048576" executionTimeout ="3600" /> </system.web> • Note: • maxRequestLength in Kb • executionTimeout in second
< Compilation> • Web Site Compilation Settings And Debug • Set Debug To true When Debugging . • Better To Set Debug To False When Deployment • Decrease Memory Size • Fasts Performance <system.net> <compilation debug="true" /> </system.net>
< Authentication> • define identity (Just User Or Member ) • ASP.Net Provide Default Database Call it (aspnet.mdf) • Generate Database Automatically by using ASP.Net Configuration From Website Menu <system.web> <authentication mode="forms" /> <system.web> Will be more in My Blog About this Later
<authorization> • Define License To Members in access Rules • Can give License to Group by using Role • Allow Access Pages And deny Others