"Reprint" Aspx,ascx and ASHX use summary

Source: Internet
Author: User

Doing ASP. Aspx,.ascx and. Ashx are not unfamiliar. About them, there are many articles on the web. "On paper to get the final feeling shallow, know this matter to preach", the following oneself summarizes to make a note.
1,. aspx
Web Forms design page. A Web Forms page consists of two parts: visual elements (HTML, server controls, and static text) and the programming Logic of the page (the Design view and code view in VS can see their corresponding files respectively). VS stores the two components separately in a separate file. Visual elements are created in the. aspx file.
2,. ascx
The user control for ASP. NET is developed as a Web page that encapsulates specific functionality and behavior, both of which are used on various pages of a Web application. A user control contains a combination of HTML, code, and other Web or user controls and is saved on the Web server in its own file format with the extension *.ascx. The default configuration in ASP. NET does not allow Web clients to access these files through URLs, but other pages of this site can integrate the features contained in these files.
3,. ashx
The first two are too familiar, this is the point to talk about.
(1), use example
The. ashx file is primarily used to write Web handler. Using the. ASHX allows you to focus on programming without the need for related web technologies. What we know about. aspx is to do HTML control tree parsing, and. aspx contains all the HTML that is actually a class, and all of the HTML is a member of the class, and this process is not needed in. ashx. The ashx must contain the IsReusable attribute (this property represents whether it is reusable, usually true), and the IRequiresSessionState interface must be implemented if you want to use the session with the Ashx file.

Analysis:
A, previously we are usually implemented through a simple ASPX file function, in fact, through the ashx can also.
The author has written an Ajax: Data transmission method Introduction, through comparison, we found that aspx to the front and back display and processing logic separate, so it made two files, in fact, in the final compilation, ASPX and CS will still be compiled into the same class. There is a need to design some logical processing of HTML, and unlike ASHX, it is simply a web The HTTP request directly returns the result that you want to return. The process of HTML is less processed than ASPX (but ashx can also handle some of the logic of HTML, which is not usually used). Theoretically ashx is faster than ASPX.
b, or in the same old text, we know several ways of data transmission, in fact ASHX can be implemented (modify the context in the Ashx file. Response.ContentType), here no longer repeat.
(2), ASHX is particularly suitable for generating dynamic images, generating dynamic text (plain text, json,xml,javascript, etc.).
(3),. ashx files have a drawback: it is cumbersome to handle postback events for controls. Processing the postback of the data usually requires the functionality of the. aspx pages, which are handled manually only by themselves (rather than by building an ASPX file directly). Therefore, it is generally used. ashx output some items that do not require postback processing.
4. Summary
Aspx-->p (Page)
Ascx-->c (Control)
Ashx-->h (HttpHandler)

When the browser accesses the Web server, we end up receiving HTML text. The browser interprets these labels through the rendering engine, showing the visible effect on the screen. and ASP. NET is a platform technology that we apply to "disguised" to explain the HTML, it is to improve productivity, it is more technical terminology, Essentially something in the HTML category (if you're not using the dynamic page technology to make full use of HTML and browser (including JS) technology to achieve dynamic page effects, Then you will find that the effect has a considerable amount of code. So the bottom of web development is a bunch of HTML tags, whether it is an ASP or JSP is a way of HTML packaging, is the product of HTML.

"Turn from" https://www.cnblogs.com/lgx5/p/5629028.html

"Reprint" Aspx,ascx and ASHX use summary

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.