Summary of ASP. net1.0 upgrade to ASP. NET 2.0

Source: Internet
Author: User

Summary of some problems found in the project from 1.0 to 2.0, and reminds friends who have not yet had time to upgrade or prepare for the upgrade to avoid detours and waste less time during the upgrade process.
1. Global. the processing format of asax files is different. An error will occur after conversion. In vs2003, global. asax has a post-code file. Under 2.0, move the code separation file to the app_code directory so that it can automatically become any ASP in the application.. NET page access. The "code-behind" attribute will be deleted from the commands in the asax file. Vs2005 directly writes the code in global. asax. Therefore, you need to delete the converted file and add it again, and copy the corresponding code.
2. project files are unavailable in 2.0. In the 1.1 application, the project file contains the configuration generation, reference to the external assembly, and the file list in the project. In the 2.0 application, version settings and file lists are no longer required, because all files in the web project directory are considered part of the web project.
3. Code separation mode.
In ASP. NET 1.1, the code separation mode separates content (such as test. aspx) from code (such as test. aspx. CS. The content page is inherited from the code separation page. The code separation page contains the code generated by the user and the designer.
ASP. NET 2.0 enhances the code separation mode by using local classes. The partial keyword can be used to separate the code of a single class into two independent files. It allows a class to span multiple files. In the new code separation mode, the content page is inherited from the compiled class. It consists of the corresponding code separation page and the automatically generated stub file, the stub file defines the field Declaration for the control used on the Content Page. This change separates the automatically generated code from the user code and significantly simplifies the code separation page. The local class structure also reduces the risk of accidentally damaging the page due to the code generated by the editing designer.
If an error occurs, check whether the partial keyword exists. Otherwise, add the partial keyword.
4. Check the syntax. ASP. in the net1.1 program, the syntax errors in files such as aspx and aspcx will not be checked during compilation, while in vs2005, the syntax in all files such as aspx and aspcx in the project will be checked. If there is a syntax error, compilation fails.
5. Control declaration. If all controls are declared on the. ASPX page, all control declarations are deleted from the code separation file; otherwise, an error is returned: Repeated definition.
6. (C # Only) Move the event hook code from the initialzecomponent function of the code separation file to the. ASPX page. Note that this operation is not applicable to automatically called events, including page_init, page_load, page_databind, page_prerender, page_unload, page_error, page_aborttransaction, and page_committransaction.
7. Deployment methods (pre-compilation, complete compilation, and updatable sites ). In 1.x, web applications are pre-compiled and deployed as a large assembly. The content page (*. aspx) is not compiled on the server, but can be edited on the server. With the new page compilation mode and directory structure, you can use different configurations to deploy ASP. NET 2.0 applications. In one case, You can pre-compile all the aspx pages and deploy a web application composed of fully compiled assemblies. In this mode, you cannot easily change the application on the server. In another case, you can deploy the application without pre-compiling any code. In this configuration, you can directly change the. ASPX page, code separation file, or any other code in the application on the server. When a user requests a page on the server, the page is dynamically compiled.
8. Change all codebehind attributes on the. ASPX page to the codefile attributes.
Codebehind: Specifies the name of the compiled file that contains the class associated with the page. This attribute cannot be used at runtime.
This attribute is provided to be compatible with previous versions of ASP. NET for code hiding. In ASP. NET 2.0, you should use the codefile attribute to specify the name of the source file, and use the inherits attribute to specify the fully qualified name of the class.
Specifies the path of the code hidden file pointing to the page reference. This property can be used together with the inherits property to associate the hidden source file of code with the webpage. This attribute is only valid for compiled pages.
9. Move all independent code files and assemblyinfo. CS to the app_code directory. However, after running the conversion wizard, you may find that some code separation files (for example, *. aspx. CS or *. ascx. VB) are moved to the app_code directory. This indicates that the content page of the code separation file contains the codebehind instruction in incorrect format and is not correctly set. That is to say, the conversion Wizard cannot determine whether the code separation file is actually bound to a specific. ASPX page.
10. Web Services
In ASP. NET 1.x, Web Services (. asmx) are automatically split into blank title pages (. asmx) and code separation files that contain actual methods.
ASP. net2.0:
Move the code separation class to the app_code directory so that it can be automatically accessed through any ASP. NET page in the application.
Change the codebehind attribute in the. asmx file to point to a new location.
(Note that the code separation file does not use a local class, so you can continue to use the codebehind attribute .)
Change all declarations of the default, friend, and internal ranges to public.

What problems have you encountered during the upgrade process? You can write it down for everyone to learn and avoid detours.

Related Article

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: 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.