ASP.NET 1.0 Upgrade to ASP.NET 2.0 Terms Summary

xiaoxiao2021-04-04  252

These days, upgraded the original 1.1 project, found some problems, summed up here, and reminded that there have been no comments to upgrade or prepare for the upgrade of friends, and less dent in the upgrade, less time.

1. Global.asax file processing form is different

After transformation, an error will appear. Global.asax in VS2003 has code post files, 2.0, move the code separation file to the app_code directory to automatically become accessible through any ASP.NET page in the application. The "Code-BEHIND" property will be removed from the command of the AsaX file. The VS2005 is written directly in Global.asax. So you need to delete the transformed file to re-join, and come over the corresponding code COPY.

2.2.0 There is no project file.

In the 1.1 application, the project file contains a reference to generate settings, references to external assemblies, and lists in the project. In 2.0 applications, version settings and file lists are no longer needed, 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 is separated from the code (such as Test.aspx.cs). The content page is inherited from the code separation page, and the code separation page contains the code generated by the user and designer.

ASP.NET 2.0 Enhances the code separation mode by using a local class, using the Partial keyword to separate the code of a single class into two separate files. It allows a class across multiple files. In the new code separation mode, the content page is inherited from the compiled class, which consists of the corresponding code separation page and the auto-generated settle file, which is used to define a field declaration for the controls used in the content page. This change causes the automatically generated code to separate from the user's code, and makes the code separation page significantly smaller and more concise. The local class structure also reduces the risk of the page due to the code generated by the editing designer.

If you have an error, please check if there is a Partial keyword, otherwise add a Partial keyword.

4. Syntax check.

ASP.NET 1.1 Program, compile, the syntax errors in files such as ASPX, ASPCX, while VS2005 checks the syntax in files in files in the project, so if there is a speech error, it will cause compilation Unable to pass.

5. Control declaration.

If all controls are declared on the .aspx page, remove all control declarations from the code separation file, otherwise an error: Repeat definition.

6. (C #) Move the event hook code from the INITIALZEComponent function of the code separation file to the .aspx page.

Note that this operation does not apply to automatic calling events, including page_init, page_load, page_unload, page_error, point_aborttransaction, and page_committransaction.

7. Deployment (precompiled, fully compiled, update sites, etc.).

In the 1.x, the web application is precompiled and deployed as a large program set. The content page (* .aspx) is not compiled on the server, but can be edited on the server. With a new page compilation mode and directory structure, you can use a variety of different configurations to deploy ASP.NET 2.0 applications. In one case, you can prepare all ASPX pages and deploy a web application consisting of fully compiled. In this mode, you cannot easily change the app on the server. Alternatively, you can deploy an application without pre-compiling any code. Under this configuration, you can change the .aspx page, code separation file, or any other code in the application directly on the server. When the user requests a page on the server, the page will be dynamically compiled. 8. Change all the CodeBehind properties in the .aspx page to the CodeFile property

CodeBehind: Specifies the name of the compiled file containing the class associated with the page. This attribute cannot be used at runtime. This property is provided for compatibility with previous versions of ASP.NET to implement code hidden features. In the ASP.NET version 2.0, you should use the CodeFile property to specify the name of the source file, and use the Inherits property to specify the fully qualified name of the class.

Codefile

Specifies the path to the code to hide the file reference page reference. This property is used with the inherits property to associate the code hidden source file with the web page. This property is only valid for compiled pages.

9. Both all separate code files and AssemblyInfo.cs are moved to the app_code directory.

However, after running the conversion wizard, you may find some code separation files (for example, *. Aspx.cs or * .ascx.vb) being moved to the app_code directory. This indicates that the content page of the code separation file contains an incorrect CodeBehind instruction and does not set correctly. That is, the conversion wizard cannot determine if the code is separated whether or not the file is actually bound to a particular .aspx page.

10.Web service

In ASP.NET 1.x, the web service (.asmx) automatically splits to blank title pages (.asmx) and code separation files that contain actual methods.

ASP.NET 2.0:

• Move the code separation class into the app_code directory to automatically change it to any ASP.NET page in the application. • Change the CodeBehind property in the .asmx file to point to the new location. (Note that the code separation file does not use a local class, so continues using the codeBehind property.) • Change all the default, Friend, and Internal range to public.

What kind of problem you have encountered during the upgrade of 1.1 to 2.0? You can write down to learn together and walk less.

转载请注明原文地址:https://www.9cbs.com/read-131782.html

New Post(0)