Page 143 - DCAP312_WEB_TECHNOLOGIES_II
P. 143

Unit 7: Advanced ASP.NET



            this section allows we to define which character set the server should use to send data to the   Notes
            client (for instance UTF-8, which is the default), and which settings the server should use to
            interpret and displaying culturally specific strings, such as numbers and dates.
                     <globalization request Encoding= “utf-8” response Encoding= “utf-8”
                     Culture= “nl-NL” />
            Encoding is done through the attributes request Encoding and response Encoding. The values
            should be equal in all one-server environments. In this example, the application culture is set
            to Dutch. If we do not supply a culture, the application will use the server’s regional settings.
                     <Http Runtime>
            We can use the http Runtime section to configure a number of general runtime settings, two of
            which are particularly convenient.
                        <http Runtime app Request Queue Limit= “100” execution Timeout= “600” />
            The first attribute specifies the number of requests the server may queue in memory at heavy-
            traffic times. In the example, if there are already 100 requests waiting to be processed, the next
            request will result in a 503 error ( “Server too busy”).The execution Timeout attribute indicates
            the number of seconds for which ASP.NET may process a request before it is timed out.
                        <session State>
            Web. Configuration file, we tell ASP.NET where to store the session state. The default is in the
            process self:
                        <session State mode= “In Proc” />
            Session variables are very powerful, but they have a few downsides. Information is lost when the
            ASP.NET process crashes, and sessions are generally useless in the case of a Web farm (multiple
            Web servers). In that instance, a shared session server can solve our issues.
                     <trace>
            Our application’s trace log is located in the application root folder, under the name trace.axd.
            We can change the display of tracing information in the trace section.
            The attributes we will look for initially are enabled: local only, and page Output.
                     <trace enabled= “true” local only= “true” page Output= “false” />
            Set local only to “false” to access the trace log from any client. If we set the value of page Output
            to “true”, tracing information will be added to the bottom of each Web page.
            Apart from  the Website  configuration  settings we  have been  talking  about in the  preceding
            paragraphs, we will know that a programmer frequently likes to use custom application-wide
            constants  to store information over multiple pages. The  most  appealing example of such  a
            custom constant is a database connection string, but we can probably think of dozens more
            from our own experience.
            The common denominator of these constants is that we want to retrieve their values
            programmatically from our code. The web. configuration file provides the possibility to do so,
            but as a security measure, these constants have to be included in the <app Settings> section
            group. Just like <system.web>, <app Settings> is a direct child tag of the Web. Configuration’s
            configuration root.
            A typical custom section group would look something like this:
                        <app Settings>
                        <add key= “sql Conn” value= “Server=myPc;Database=Northwind” />
                        <add key= “ smtp Server” value= “smtp.mydomain.com” />
                        </appSettings>




                                             LOVELY PROFESSIONAL UNIVERSITY                                   137
   138   139   140   141   142   143   144   145   146   147   148