ASP. NET basics: Foundation of ASP. NET

Source: Internet
Author: User
Tags configuration settings what is asp

After reading the recommendations of dflying Chen, extract the articles for the interviewees.

This has been pooled together from a number of resources:

What is ASP. NET?

Microsoft ASP. net is a server side technology that enables programmers to build dynamic web sites, web applications, and XML Web Services. it is a part of. net Based environment and is built on the Common Language Runtime (CLR ). so programmers can write ASP. net code using any. net compatible language.

What are the differences between ASP. NET 1.1 and ASP. NET 2.0?

A comparison chart containing the differences between ASP. NET 1.1 and ASP. NET 2.0 can be found over here.

Which is the latest version of ASP. NET? What were the previous versions released?

The latest version of ASP. NET is 2.0. There have been 3 versions of ASP. NET released As of date. They are as follows:

ASP. NET 1.0-released on January 16,200 2.

ASP. NET 1.1-released on each l 24,200 3.

ASP. NET 2.0-released on November 7, 2005.

Additionally and ASP. NET 3.5 is tentatively to be released by the end of the 2007.

Explain the event life cycle of ASP. NET 2.0?

The events occur in the following sequence. its best to turn on tracing (<% @ page trace = "true" %>) and track the flow of events:

Preinit-This event represents the entry point of the page life cycle. if you need to change the master page or theme programmatically, then this wocould be the event to do so. dynamic controls are created in this event.

Init-Each control in the control collection is initialized.

Init complete*-Page is initialized and the process is completed.

Preload*-This event is called before the loading of the page is completed.

Load-This event is raised for the page and then all child controls. The controls properties and view State can be accessed at this stage. This event indicates that the controls have been fully loaded.

Loadcomplete*-This event signals indicates that the page has been loaded in the memory. It also marks the beginning of the rendering stage.

Prerender-If you need to make any final updates to the contents of the controls or the page, then use this event. It first fires for the page and then for all the controls.

Prerendercomplete*-Is called to explicitly state that the prerender phase is completed.

Savestatecomplete*-In this event, the current state of the control is completely saved to the viewstate.

Unload-This event is typically used for closing files and database connections. At times, it is also used for logging some wrap-up tasks.

The events marked with * have been introduced in ASP. NET 2.0.

You have created an ASP. NET application. How will you run it?

With ASP. NET 2.0, Visual Studio comes with an inbuilt ASP. net Development Server to test your pages. it functions as a local web server. the only limitation is that remote machines cannot access pages running on this local server. the second option is to deploy a web application to a computer running IIS version 5 or 6 or 7.

Explain the autopostback feature in ASP. NET?

Autopostback allows a control to automatically PostBack when an event is fired. for eg: if we have a button control and want the event to be posted to the server for processing, we can set autopostback = true on the button.

How do you disable autopostback?

Hence the autopostback can be disabled on an ASP. NET page by disabling autopostback on all the controls of a page. autopostback is caused by a control on the page.

What are the different code models available in ASP. NET 2.0?

There are 2 code models available in ASP. NET 2.0. One is the single-file page and the other one is the code behind page.

Which base class does the web form inherit from?

Page class in the system. Web. UI namespace.

Which are the new special folders that are introduced in ASP. NET 2.0?

There are seven new folders introduced in ASP. NET 2.0:

\ App_browsers folder-Holds browser definitions (. Brower) files which identify the browser and their capabilities.

\ App_code folder-Contains source code (. CS ,. VB) files which are automatically compiled when placed in this folder. additionally placing web service files generates a proxy class (out. WSDL) and a Typed Dataset (out. XSD ).

\ App_data folder-Contains data store files like. MDF (SQL express files),. mdb, XML files etc. This folder also stores the local dB to maintain membership and role information.

\ App_globalresources folder-Contains Assembly resource files (. resx) which when placed in this folder are compiled automatically. in earlier versions, we were required to manually use the resgen.exe tool to compile resource files. these files can be accessed globally in the application.

\ App_localresources folder-Contains Assembly resource files (. resx) which can be used by a specific page or control.

\ App_themes folder-This folder contains. CSS and. Skin files that define the appearance of web pages and controls.

\ App_webreferences folder-Replaces the previusly used web references folder. This folder contains the. Disco,. WSDL,. XSD files that get generated when accessing remote web services.

Explain the viewstate in ASP. NET?

HTTP is a stateless protocol. hence the state of controls is not saved between postbacks. viewstate is the means of storing the state of server side controls between postbacks. the information is stored in HTML hidden fields. in other words, it is a snapshot of the contents of a page.

You can disable viewstate by a control by setting the enableviewstate property to false.

What does the enableviewstate property signify?

Enableviewstate saves the state of an object in a page between postbacks. objects are saved in a base64 encoded string. if you do not need to store the page, turn it off as it adds to the page size.

There is an excellentArticleBy Peter Bromberg to understand viewstate in depth.

Explain the ASP. NET page directives?

Page directives configure the runtime environment that will execute the page. The complete list of directives is as follows:

@ Assembly-links an assembly to the current page or user control declaratively.

@ Control-Defines control-specific butes used by the ASP. NET page parser and compiler and can be encoded only in. ascx files (user controls ).

@ Implements-indicates that a page or user control implements a specified. NET Framework interface declaratively.

@ Import-imports a namespace into a page or user control explicitly.

@ Master-identifies a page as a master page and defines attributes used by the ASP. NET page parser and compiler and can be supported ded only in. Master files.

@ Mastertype-defines the class or virtual path used to type the master property of a page.

@ Outputcache-controls the output caching policies ies of a page or user control declaratively.

@ Page-Defines page-specific butes used by the ASP. NET page parser and compiler and can be encoded only in. aspx files.

@ Previouspagetype-creates a stronugly typed reference to the source page from the target of a cross-page posting.

@ Reference-links a page, user control, or COM control to the current page or user control declaratively.

@ Register-associates aliases with namespaces and classes, which allow user controls and custom server controls to be rendered when added in a requested page or user control.

This list has been taken from here.

Explain the validation controls used in ASP. NET 2.0?

Validation controls allows you to validate a control against a set of rules. There are 6 different validation controls used in ASP. NET 2.0.

Requiredfieldvalidator-checks if the control is not empty when the form is submitted.

Comparevalidator-compares the value of one control to another using a comparison operator (equal, less than, greater than etc ).

Rangevalidator-checks whether a value falls within a given range of number, date or string.

Regularexpressionvalidator-confirms that the value of a control matches a pattern defined by a regular expression. eg: email validation.

Customvalidator-callyour own valim validation logic to perform validations that cannot be handled by the built in validators.

Validationsummary-show a summary of errors raised by each control on the page on a specific spot or in a message box.

How do you indenied that the page is post back?

By checking the ispostback property. If ispostback is true, the page has been posted back.

What are master pages?

Master pages is a template that is used to create web pages with a consistent layout throughout your application. master pages contains content placeholders to hold page specific content. when a page is requested, the contents of a master page are merged with the content page, thereby giving a consistent layout.

How is a master page different from an ASP. NET page?

The masterpage has a @ master top directive and contains contentplaceholder server controls. It is quiet similar to an ASP. NET page.

How do you attach an exisiting page to a master page?

By using the masterpagefile attribute in the @ page ctictive and removing some markup.

How do you set the title of an ASP. NET page that is attached to a master page?

By using the title property of the @ page Directive in the content page. eg:

<@ Page masterpagefile = "sample. Master" Title = "I hold content" %>

What is a nested master page? How do you create them?

A nested master page is a master page associated with another master page. to create a nested master page, set the masterpagefile attribute of the @ master directive to the name of. master file of the Base master page.

What are themes?

Themes are a collection of CSS files ,. skin files, and images. they are text based style definitions and are very similar to CSS, in that they provide a Common Look and Feel throughout the website.

What are skins?

A theme contains one or more skin files. A skin is simply a text file with a. Skin extension and contains definition of styles applied to server controls in an ASP. NET page. For eg:

<Asp: button runat = "server" backcolor = "blue" bordercolor = "gray" font-bold = "true" forecolor = "white"/>

Defines a skin that will be applied to all buttons throughout to give it a consistent look and feel.

What is the difference between skins and CSS files?

CSS is applied to HTML controls whereas skins are applied to server controls.

What is a user control?

User Controls are reusable controls, similar to web pages. They cannot be accessed directly.

Explain briefly the steps in creating a user control?

· Create a file with. ascx extension and place the @ control direve ve at top of the page.

· Added the user control in a web forms page using a @ register directive

What is a custom control?

Custom Controls are compiled components that run on the server and that encapsulate user-interface and other related functionality into reusable packages. they can include all the design-time features of standard ASP. net server controls, including full support for Visual Studio design features such as the Properties window, the visual designer, and the toolbox.

What are the differences between user and custom controls?

User Controls are easier to create in comparison to custom controls, however user controls can be less convenient to use in advanced scenarios.

User Controls have limited support for consumers who use a visual design tool whereas custom controls have full visual design tool support for consumers.

A separate copy of the user control is required in each application that uses it whereas only a single copy of the custom control is required, in the Global Assembly Cache, which maintenance easier.

A user control cannot be added to the toolbox in Visual Studio whereas custom controls can be added to the toolbox in Visual Studio.

User Controls are good for static layout whereas custom controls are good for dynamic layout.

Where do you store your connection string information?

The connection string can be stored in configuration files (Web. config ).

What is the difference between 'web. config' and 'machine. config '?

Web. config files are used to apply configuration settings to a particle web application whereas machine. config file is used to apply configuration settings for all the websites on a Web server.

Web. config files are located in the application's root directory or inside a folder situated in a lower hierarchy. The machine. config is located in the Windows directory Microsoft. NET \ framework \Version\ Config.

There can be multiple web. config files in an application nested at different hierarchies. However there can be only one machine. config file on a Web server.

What is the difference between server. Transfer and response. Redirect?

Response. redirect involves a roundtrip to the server whereas server. transfer conserves server resources by avoiding the roundtrip. it just changes the focus of the webserver to a different page and transfers the page processing to a different page.

Response. Redirect can be used for both. aspx and HTML pages whereas server. transfer can be used only for. aspx pages.

Response. redirect can be used to redirect a user to an external websites. server. transfer can be used only on Sites running on the same server. you cannot use server. transfer to redirect the user to a page running on a different server.

Response. redirect changes the URL in the browser. so they can be bookmarked. whereas server. transfer retains the original URL in the browser. it just replaces the contents of the previous page with the new one.

What method do you use to explain icitly kill a users session?

Session. Abandon ().

What is a WebService?

Web services are applications delivered as a Service on the web. web services allow for programmatic access of business logic over the web. web Services typically rely on XML-based protocols, messages, and interface descriptions for communication and access. web services are designed to be used by other programs or applications rather than directly by end user. programs invoking a web service are called clients. soap over HTTP is the most commonly used protocol for invoking Web Services.

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.