Simplifies maintenance of older versions of ASP.net programs using the src attribute of the @page directive

Source: Internet
Author: User
Tags command line net versions
Asp.net| Program  

In a blink of an eye, it's been 4 years since Microsoft launched the. NET platform, and. NET has also experienced upgrades from 1.0 to 1.1 to 2.0. Attracted by the ASP.net 2.0 and the various superior features of the VS. the IDE, everyone is busy learning 2.0 and upgrading the project to VS 2005 under development. In practice, however, many projects cannot be upgraded to a new version for a variety of reasons. As time has changed, older versions of project maintenance issues have become more and more of a headache. Although. NET birth time is not long, but 4 years of time enough to accumulate a quantity of projects.
I have a project developed with Vs.net 2002 that has not been upgraded for a variety of reasons (mainly because the project has been running well for some time before Vs.net 2003, and other asp.net programs on the server are unable to adapt to the security requirements of. NET 1.1. )
When the company development platform upgrade, on the computer at the same time installed Vs.net 2002 and Vs.net 2003, temporarily solve the different versions of the maintenance of the project. Later, the project has been maintenance period, for a long time did not update, my computer also reload, Vs.net 2002 completely swept out. Can be 2005 years, customers every 1, 2 months on the request for change, and fast, no way, customers too cow B, over the maintenance period to be changed. But the problem comes, no vs 2002, can't compile AH.
Install a. NET Framework 1.0 on a computer, use manual method to call CSC compile modified code, very troublesome, project has a bunch of references, writing command line is very complicated. Especially when items have many folders that are more painful. Also tested to write a program compiled, but I lazy, has not been achieved.
    today comes up to modifying the program, suddenly thinking of the early (2002) use of a @Page directive SRC attribute, using this property, ASP.net will adopt its own compilation model instead of using vs.net The IDE's codebehind way, the code can be published without compiling it into a DLL, and asp,net automatically compiles the aspx file with the. aspx.vb file when accessing the site. The disadvantages of this approach are mainly two: 1, code files (. vb) must be published to the server,  2, vs.net IDE does not support. Because of the second problem, and then give up the use of it, it is forgotten. Now there is no way to compile the program, as long as the code can be modified to take effect, other shortcomings are not filtered. Anyway, all the source code is posted to the server. I added a src attribute to the @page directive that uses the same value as the Codebehind property to point to the code file. Then modify the code in the. vb file to complete. Refreshes, changes take effect, maintenance complete. Oh, cool. I'll do it in the future. Because the vs.net IDE is not supported, MSDN is also a one-off, and not many people know that. NET has this compilation model. Now share it out, if someone is also suffering me the same pain, you can also test filter in the page to add src, oh, simple and quick, change the code on the entry into force, no longer have to rack their brains to find tools compiled.

Summary: Many people, including me, prefer to compile the program into a DLL, which feels more like a published software. In fact, the adoption of "all source code to the server, runtime complete compilation code," The way is very good, greatly simplifying the future maintenance work. Many companies do not need to hide source code from customers for their clients ' projects. In this case, the use of this way for future maintenance work brings great benefits, regardless of. NET Upgrade n times, regardless of whether your computer is equipped with the appropriate version of the development tools, you do not have to worry about, with Notepad can handle everything.

Note: All versions of ASP.net support this compilation mode, but Vs.net 2002 and 2003 do not support the IDE and cannot open Design view. Just out of the VS. the IDE supports this compilation pattern.  When using the SRC attribute, the Codebehind property is no longer needed, but it is recommended that you still keep it, if you suddenly need to return to the meter view, it can also help you. Inherits properties are not required, but it is strongly recommended that you do not delete it, because if you bind an event directly in the control declaration of an ASPX file (such as:), no Inherits property will complain.

Source: Cwbboy BLOG



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