ASP. NET code hidden files

Source: Internet
Author: User

ASP. net mvc still uses WebFormsViewEngine by default. When Visual Studio is used to add a WebForms View to the ASP. net mvc application, a code hidden file and a designer file are automatically added. Many people think that code hidden files have been deprecated and their usage is confusing, because developers tend to use views like traditional ASP. NET Web forms.

Steve Smith further demonstrated the disadvantages of the ASP. net mvc Codebehind file because they tempted developers to add logic to the view, and the view should be "dumb" in design ".

Hiding files in code is a temptation. Not familiar with ASP. net mvc (ASP. net mvc has not been released yet in less than a year. But developers with Web forms development background (MOST) always have a tendency to write code into hidden code files. This makes the logic in the view difficult to test. The worst possibility is that the logic contained in the hidden code file directly calls the database or web service, and thus completely bypasses the separation of the model from the view.

Steve explains that hiding a file in code is a bad but essential thing in some situations. For example, you want to reference a Model in a strongly typed view ). Some writers think that the hidden code page can also be used to store some view logic, while other methods may confuse the ASPX file. Last but not least, they want to get support for smart tip technology on the ASPX file. As for the first question, Tim Barcz demonstrated how to use ViewData without code to hide and use strong ViewData. Instead of C # Or VB by combining generic CLR notation.

  1. Introduction to ASP. net mvc Framework
  2. Introduction to MvcAjaxPanel in ASP. NET MVC
  3. ASP. net mvc Framework to save UpdatePanel
  4. Use ASP. net mvc source code to find a solution
  5. ActionInvoker of ASP. net mvc Framework

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.