App_Code : You know what this is right?
App_Data : Contain database or data source files.
App_GlobalResources : Contains resource files that are global to any aspx page.
App_LocalResources : Contains page specific resource files.
App_WebReferences : Contains Web/WCF Service reference files
Theme : Contains theme definition files
App_Browsers : ?
App_Browsers may be the least known and used among these folders. Lets have a basic idea what this folder is and how to use it in an Asp.net application/web site.
When a Request arrives at an Asp.net application/web site, the Asp.net run time reads some information in the Request header to determine the client browser and it's capability. Once read, the identity of the browser is stored in the Request.UserAgent property, and, the capability of the browser is stored in the Request.Browser property.
Based upon the browser information, Asp.net server controls may emit different XHTML markups so that, the ultimate content is rendered correctly on the client agent (Note, I referred the term "Client agent", not "browser").
You may wonder why this is needed. Each server control should emit standard XHTML and each client agent (browser) should be able to render those properly, right?
Unfortunately, the answer is "No". There are quite a few XHTML standards out there ,some of which are very strict (Say, XHTML 1.0 Strict) and some of which are not (Say, XHTML 1.0 Transitional). Not all browsers are capable to understand these all XHTML standards and render the contents correctly to the output. Moreover, not all "client agents" are PC browsers. These days, lots and lots of request may arrive from hand held devices which may have browsers with capability which is not equal to the capability of PC browsers.
So, there has to be a way for the Asp.net applications (Or, web sites) to determine the type and capability of the browser and to emit the correct XHTML markup for each Asp.net server control. You may not require to configure this always (As most browsers understand the XHTML standards and they can render roughly the correct output to the browser if the server controls and corresponding XHTML are written properly), but, you may want to configure the rendering capability/style for some particular type of browsers (Say, for a particular browser used in a handheld device) if you know your application could be browsed by that browser.
"App_Browsers" folder lets you do this. All you need to do is to put a browser definition file inside this folder (a file that has the .browser extension), and, configure the file according to your need. In earlier versions of Asp.net, there were no "App_Browsers" folder, and, the browser capabilities had to be configured in web.config file (Using the <browserCaps> element).
If you add a .browser file within the "App_Browsers" folder from within the Visual Studio, you will see a .browser file being added there (The name could be anything, the extension matters) and the file contains the following markup:
<!--
You can find existing browser definitions at
<windir>\Microsoft.NET\Framework\<ver>\CONFIG\Browsers
-->
<browsers>
<browser id="NewBrowser" parentID="Mozilla">
<identification>
<userAgent match="Unique User Agent Regular Expression" />
</identification>
<capture>
<userAgent match="NewBrowser (?'version'\d+\.\d+)" />
</capture>
<capabilities>
<capability name="browser" value="My New Browser" />
<capability name="version" value="${version}" />
</capabilities>
</browser>
<browser refID="Mozilla">
<capabilities>
<capability name="xml" value="true" />
</capabilities>
</browser>
</browsers>At run time, Asp.net reads the browser definition file, and, renders the XHTML markups for the server controls as instructed there if the current client agent is configured in the file.
You would obviously want to change this default configuration, and, you may want to take a look at http://msdn.microsoft.com/en-us/library/ms228122.aspx to learn how to do this.
1 comment:
very useful
Post a Comment