introduction to xml and using web config file n.
Skip this Video
Loading SlideShow in 5 Seconds..
Introduction To XML and using web.config file PowerPoint Presentation
Download Presentation
Introduction To XML and using web.config file

Loading in 2 Seconds...

play fullscreen
1 / 17

Introduction To XML and using web.config file - PowerPoint PPT Presentation

Download Presentation
Introduction To XML and using web.config file
An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Introduction To XMLand using web.config file

  2. Topics • What is XML • History • Motivation • Where/Who uses XML • When to use/not use

  3. What Is XML • Data formatted in a way that is easy for humans and machines to read • eXtensible Markup Language • Text data, i.e. not binary • When stored in a file, one can view it with Notepad • Not a language • Fast becoming a universal data translation language

  4. Example <?xml version="1.0"?> <CustomerList> <customer id="1"> <fname> Jen </fname> <lname> Lo </lname> <title> CEO </title> <company> Blue Moon Enterprises </company> </customer> <customer id="2"> <fname> Austin </fname> <lname> Powers </lname> <title> Gold Member </title> <company> MiniEvil </company> </customer> </CustomerList>

  5. XML’s History • Specs published in Feb 1998 • Began to get popular in 2000 • Supported by most vendors and platforms • MS, IBM, Sun, Borland, … • I.E. >= 5.0 can display XML data

  6. Motivation • Businesses needed to communicate over the Internet. (B2B) • Send documents and complex data that have different formats • Word, PDF, Excel, Access, comma separated, … • E.g. think how many ways a person’s name can be formatted • Different Internet clients capabilities. • Desktops with different browsers • PDAs, Mobile phones, …

  7. Where/Who Uses XML • In databases to store or move data • In configuration files • In communication between systems • MS: .NET, IE, SQL Server, …

  8. To Use Or Not To Use • Use when you want to: • Communicate between different programs and systems • Store complex configuration data • Display output by different clients, e.g. desktops and PDAs. • Do not use when: • You need a relational database model, XML is less efficient than RDBs

  9. XML Technologies • The following slides will introduce some XML related terms and technologies • This a high level definition

  10. Tags And Elements Consider the following XML snippet: <customer id="2"> <fname> Austin </fname> <lname> Powers </lname> <title> Gold Member </title> <company> MiniEvil </company> </customer> • <fname> is a start tag • </fname> is an end tag • <fname>Austin</fname> is an element • id (in customer tag) is an attribute

  11. Well-Formed XML Document • Well-Formed document: • Follows XML syntax • Every start tag must have an end tag • If a document is not well-formed, then it is NOT an XML document

  12. Web.config file • Web.config is the main settings and configuration file for an ASP.NET web application. • The file is an XML document that defines configuration information regarding the web application. • The web.config file contains information that control module loading, security configuration, session state configuration, and application language and compilation settings. • Web.config files can also contain application specific items such as database connection strings.

  13. Web.config File <configuration> • <appSettings> • <add key="abc" value=“a certain value"/> • </appSettings> • <connectionStrings> • <add name="TestingConnectionString1" connectionString="Data Source=.;Initial Catalog=Testing;Integrated Security=True" providerName="System.Data.SqlClient"/> • </connectionStrings> • <system.web> • <compilation debug="true" strict="false" explicit="true"/> • <pages> • <namespaces> • <clear/> • <add namespace="System"/> • <add namespace="System.Collections"/> • <add namespace="System.Collections.Specialized"/> • <add namespace="System.Configuration"/> • <add namespace="System.Text"/> • <add namespace="System.Text.RegularExpressions"/> • <add namespace="System.Web"/> • <add namespace="System.Web.Caching"/> • <add namespace="System.Web.SessionState"/> • <add namespace="System.Web.Security"/> • <add namespace="System.Web.UI"/> • <add namespace="System.Web.UI.WebControls"/> • <add namespace="System.Web.UI.WebControls.WebParts"/> • <add namespace="System.Web.UI.HtmlControls"/> • </namespaces> • </pages> • <authentication mode="Windows"/> • </system.web> </configuration>

  14. Web.config File • At this point, we are interested in the web.config part that is highlighted in red in the previous example. • appSettings section • Contains custom application settings, such as file paths, XML Web service URLs.

  15. Web.config File • Ex) <appSettings> <add key=“imgsPath" value=“~/images/"/> </appSettings> • connectionStrings section: • Specifies a collection of database connection strings, as name/value pairs, for ASP.NET applications and features.

  16. Web.config File • Ex) <connectionStrings> <add name=“connStr“ connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Testing;Integrated Security=True" providerName="System.Data.SqlClient"/> </connectionStrings>

  17. Web.config File • To retrieve a value from appSettings section and use it in ASP.NET code: ConfigurationManager.AppSettings(“app_name") • To retrieve a value from connectionString section and use it in ASP.NET code: ConfigurationManager.ConnectionStrings(“conStr").ConnectionString