VS in the role of folders such as Bin,app_code,app_data,app_browser,app_globalresources.

Source: Internet
Author: User
Tags naming convention sql server express

1. Bin folder

The Bin folder contains the deployable assemblies required by the application for controls, components, or any other code that needs to be referenced. any. dll files that exist in the directory are automatically linked to the application. If you leave unused or outdated files in this folder, you may have the risk of an ambiguity reference (ambiguous reference) exception . In other words, if two different assemblies define the same class (the same namespace and name), the ASP cannot decide which assembly should be used, thereby throwing an exception. At development time, this is a common error when we rename an item or an assembly name. To avoid this error, be sure not to keep any unnecessary assemblies in the folder, or at least remove the following lines of code from the <assemblies> section of the configuration file:

<add assembly= "*"/> (Note: ************* the currently applied assembly)

2. App_Browser folder

The optional folder contains the. browser file. The. browser file describes the features and functionality of the browser, whether it is a mobile device browser or a desktop browser. Asp. NET installs a large number of. browser files in the Config\browser folder under the installation path, which are shared by all applications . We just place the current application-specific browser file under the App_Browser folder. The contents of the. browser file are compiled on the fly dynamically to provide the most up-to-date browser information to the ASP.

Let's talk a little about having a custom. browser file may help you with a scenario. Imagine an application that uses a control that cannot be rendered effectively under a browser. When you display a host page in a specified browser, you can write a. browser file that forces ASP. NET to use a different adapter to build the control.

[HTML]View Plaincopyprint?
  1. <browsers>
  2. <browser id="Browserid">
  3. <controladapters>
  4. <adapter controltype="Samples.customcontrol"
  5. Adaptertype="Samples.Adapters.CustomControlAdapter" />
  6. </controladapters>
  7. </Browser>
  8. </browsers>
<browsers> <browser  id= "Browserid" > <controlAdapters> <adapter  controltype= " Samples.customcontrol "adaptertype=" Samples.Adapters.CustomControlAdapter "  

Assuming that the Browserid matches one of the standard browsers that ASP. NET recognizes, the. browser file shown above indicates that the Customcontroladapter rendering CustomControl is used under the specified browser.

3. App_Code folder

The App_Code folder is exactly at the root of the Web application and stores all class files that should be dynamically compiled as part of the application . These class files are automatically linked to the application without the need to add any explicit directives or declarations to the page to create the dependencies . The class file that is placed in the App_Code folder can contain any recognizable ASP. NET Components- custom controls, auxiliary classes, build providers, business classes, custom providers, HTTP handlers, and so on.

Note When you develop, changes to the App_Code folder cause the entire application to recompile. For large projects, this may not be welcome and time consuming. To do this, you are encouraged to modularize the code into different class libraries, organized logically by the associated set of classes. Most of the application-specific helper classes should be placed in the App_Code folder.

All class files stored in the App_Code folder should use the same language. If a class file is written in two or more languages, you must create a subdirectory of a specific language to contain the classes written in each language. Once these class files are organized according to the language, you will add a setting for each subdirectory in the Web. config file:

[HTML]View Plaincopyprint?
    1. <compilation >   
    2.   
    3. << Span class= "Tag-name" >codesubdirectories>   
    4.   
    5. <add   directoryname= "Vbfolder"   / >   
    6.   
    7. </codesubdirectories>   
    8.   
    9. </ Compilation>   
<compilation> <codeSubDirectories> <add  directoryname= "Vbfolder"  

It is important that a specific language subdirectory be registered in the Web. config file, otherwiseall files under the App_Code folder will be compiled into a separate assembly, regardless of which folder they belong to. The preceding configuration script describes a situation in which all C # files are placed in the root directory of the App_Code folder and several Visual Basic. NET class files into the Vbfolder directory. If the directory mentioned in the <codeSubDirectories> section does not exist, you will receive a compile error prompt.

Files in the App_Code root folder are compiled into App_code_xxx.dll assemblies, where xxx is a randomly generated sequence of characters. A file in a given subdirectory will be compiled into a dynamically created assembly named App_subcode_xxx_yyy.dll, where xxx indicates the name of the subdirectory, and yyy is a random sequence of characters. The,<codesubdirectories> section is only valid if it is set in the Web. config file in the application root directory.

To place a AssemblyInfo.cs file in the App_Code directory or any other subdirectory, you can create a strong-named assembly. Obviously, if the folder contains visual Basic. NET file, then the AssemblyInfo.vb file will be used. An assembly configuration file can reference an. snk file to hold a strong-named key.

Note To set a strong name for an assembly, you must first obtain a public/private key pair. Such a key pair can be obtained by using the strong name (Strong name) tool (Sn.exe). The Strong Name tool is one of the SDK binary that we can find in the installation path of the. NET Framework. A key pair file typically has an. snk extension. You can save the file to an application folder and reference it in the AssemblyInfo.cs file as follows:

[Assembly:assemblykeyfileattribute (@ "Yourkeypair.snk")]

Note that Visual Basic. NET is to look for a key file in a directory that contains visual Studio solution, while the C # compiler looks for a key file in the directory that contains the binary. As you know, use this property to adjust the path we use, or to put the key file in the appropriate folder.

In any subsequent rebuilds, the name of the assembly changes. At the same time, the old AppDomain requests the end to delete the old assembly.

The App_Code folder does not contain only class files. In particular, it can contain and be able to automatically process XSD files that represent data schemas. When you add an XSD file to the folder, the compiler resolves it to a typed dataset class and adds it to the application scope. In ASP. 1.x, this work is done by Visual Studio. NET Wizard, which is done using a command-line utility (Xsd.exe).

Note When you use the Web. config file to register a component (for example, a custom server control or a custom HTTP handler), you typically require that you specify the assembly name that contains the code. If the component is defined in the App_Code folder, what name should be used to indicate the assembly? In this case, only the assembly information is ignored and the full class name is specified. If no assembly is specified, the ASP. NET runtime attempts to mount the class from any mounted assembly, including the Assembly that was created dynamically for the App_Code folder.

4. App_Data folder

The App_Data folder should contain the application's local data store. It typically contains data stores in the form of files, such as Microsoft Access or Microsoft SQL Server Express databases, XML files, text files, and any other files that your application supports. The contents of this folder are not processed by ASP. This folder is the default location where the ASP. NET provider stores its own data.

Note The default ASP. NET account is granted full access to the folder. If you happen to be changing an ASP. NET account, make sure that the new account is granted read/write access to the folder.

5. App_GlobalResources Folder

Just like other applications, ASP. NET applications can also use resources, and resources should typically be used. Resources are an efficient way to isolate the localized portions of an application's user interface. In general, a resource is a program-related non-executable text. Typical resources are images, icons, text, and satellite files, but any serializable object can also be considered a resource. Application resources are stored outside the application so that they can be recompiled and replaced without affecting and recompiling the application itself.

Asp. NET application requires a primary assembly to hold the application's default or neutral resources. In addition, many satellite assemblies are deployed, each containing localized resources for a culture that we need to support. In ASP. NET 1.x, it's a little cumbersome to compile resources in one assembly. You need to manually compile the XML-based resource files (those with the. res extension) into a. resources binary file. These files can be embedded in a single. NET executable file, or it can be compiled into a satellite assembly. Use the Resource File Builder utility, Resgen.exe, to convert text and XML-based resource files into. resource files. The resource file name follows the BaseName.cultureName.resource naming convention, where basename is typically the name of the application:

Resgen.exe Proaspnet20.resx ProAspNet20.it.resources

After you create the. resource file, you should embed it in an assembly and even use it as a resource container. To embed a resource file into a satellite assembly, you can use the Assembly Connector tool (Al.exe). On the command line, indicate the culture used by the Assembly (as it is in the example below, which represents Italy) and the name.

Al/out:proaspnet20.resources.dll/c:it/embed:proaspnet20.it.resources

After the satellite assemblies are compiled, they will have the same name. Deploy them to different subdirectories, named by culture, respectively.

Fortunately, for ASP. NET 2.0, the era of satellite assemblies is gone. More precisely, satellite assemblies still exist, but because App_GlobalResources retains folders, they have become a thing of the past for developers.

Any located. resx files in the folder are automatically compiled into satellite assemblies. The name of the. resx file contains cultural information to help build the assembly of the ASP. NET runtime environment. The following files, Resources.resx, Resources.it.resx, resources.fr.resx, generate neutral assemblies and satellite assemblies suitable for Italian (Italian) and French (French) cultures. If a specific culture is not required, the neutral assembly is the default cultural resource.

The resource file in the App_GlobalResources folder is the global resource for the application and can be referenced from any page. The result of resource reading compared to the ASP. NET 1.x is greatly simplified:

<asp:label runat= "Server" text= "<%$ resources:resxfile, Myresname%>"/>

You can use the latest $-expressions called resources to bind global resources declaratively (the 5th chapter details the $-expression). The expression includes two parameters: the name of the. resx resource file (without the extension), and the name of the resource to retrieve. To access resources programmatically, use the following code:

Httpcontext.getglobalresourceobject (Resxfile, Myresname)

Both of these parameters are strings and have the same effect as parameters in the $-expression. In addition, the implementation of the $-expression resources uses getglobalresourceobject internally.

6. App_LocalResources Folder

The App_LocalResources folder is located in a subdirectory under a folder that contains some ASP. The folder can be populated with a. resx file that is named after a page in a higher-level directory in the directory structure. Assuming that the parent folder contains Test.aspx, you can find some of the available resource files in the App_LocalResources folder as follows: Test.aspx.resx, Test.aspx.it.resx, and Test.aspx.fr.resx. Obviously, the resources stored in the above files only have an impact on the Test.aspx page, so they can only be seen in the linked pages (they are available).

How do I access a page-specific resource? For programmatic access, you can use the following code:

Httpcontext.getlocalresourceobject ("/proaspnet20/respage.aspx",

"Pageresource1.title")

The 1th parameter indicates the page virtual path, and the 2nd parameter is the resource name. For declarative access, use the Meta:resourcekey property. For example

<asp:button runat= "Server" meta:resourcekey= "ButtonResource1"/>

The Declaration associates a unique resource key with a specific button instance. The local file. resx contains entries in prefix.name form, where prefix is a resource key, and name is the property name on the bound control. To give the button a localized caption (the Text property), simply create a buttonresource1.text entry in the resource file.

Resource files that exist in the local and global resource folders are compiled to create a class of satellite assemblies. The final result is that the developer creates the. resx file and tests the page. The ASP. NET compilation mechanism will complete the rest of the work.

7. App_Themes Folder

The App_Themes folder defines the theme for the ASP. The theme is contained in a folder under the App_Themes folder. By definition, a topic is a set of files with style information. The contents of the files in the theme folder are compiled to generate a class that is programmatically styled by a page call to set the theme control.

The App_Themes folder lists the local topics for the application. The application can also inherit global topics defined in the following folder:

%windows%\microsoft.net\framework\[version]\asp.netclientfiles\themes

From a compilation perspective, there is no difference between a global theme and a local theme. If a topic of the given name has both a local theme for the application and a global theme for the server machine, then the local theme takes precedence.

8. App_WebReferences Folder

In Visual Studio. NET 2003, a Web application that needs to access the website will get the corresponding. wsdl file through the Add Web Reference dialog box. The WSDL (Web service Description Language) document for Web services is not sufficient for Web services to be used from a page. Asp. NET page is ultimately a managed class and needs to communicate with another managed class. Therefore, the Web service is wrapped by a proxy class. The proxy class was created by Visual Studio services using the command-line tool Wsdl.exe. The proxy class tries to contain as many methods as the Web service provider's Web method, and it combines any custom data types defined by the common interface of the Web services.

This operation does not require the developer to pay a significant price. However, developers obviously have to rely on Visual Studio to generate proxy classes. Wouldn't it be easier and easier to put the. wsdl file directly somewhere in the application's directory tree and have ASP. NET handle the rest of the tasks? This is exactly what the App_WebReferences folder is going to do.

It identifies the. wsdl file that is used to describe the Web service being bound and generates a runtime proxy class so that the ASP. NET page can place a call to the Web service in a type-safe manner. The App_WebReferences folder can contain subfolders. The name of the subfolder drives the namespace of the last resulting proxy class, and the WSDL file defines the class name. For example, the samples.wsdl file and the ProsAspNet20 subfolder create a proxy class called Proaspnet20.samples. The dynamically created assembly is called App_WebReferences.xxx.dll, where xxx is a random sequence of characters.

folder name
  file type
  Note       Release
 
Bin
 . dll
  include any pre-built assemblies required by the application
 
App_Browsers
 . Browser
  contains application-specific browser definition files, ASP. NET uses it to identify browsers and determine their capabilities
 
App_Code
 . cs,. vb,. xsd, custom file types
  contains the source files for the classes that are compiled as part of the application. When the page is requested, ASP. NET to compile the code in this folder. The code in this folder is automatically referenced in the application
 
App_Data
 . mdb,. mdf,. xml
  contains microsoft  office  Access and sql  Express files, as well as XML files or other data stores
 
App_GlobalResources
 . resx
  Contains resource files that are programmatically used in localized applications
 
App_LocalResources
 . resx
  resource files that contain page ranges
 
App_ Themes
 . Skin,. CSS,. xsl, satellite files
  contains a set of files that define the appearance of ASP. NET pages and controls
 
App_WebReferences
 . wsdl
  Contains the WSDL file used to generate the proxy class, and other files related to using the Web service in the application

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.