You are currently viewing 4. Asp.net

4. Asp.net

What is Asmx?

Building a web service. Needs to be updated with WSDL

What is Ashx?

Resource files.  Like classes that provide functionality

What is aspx?

Active server pages

Explain state Management in detail?

Preserving Data for communication on or between pages, or across web applications. Features are listed below:

FEATURES:

  • View state
  • Control state
  • Hidden fields
  • Cookies
  • Query strings
  • Application state
  • Session state
  • Profile Properties

1) Explain Authorization and Authentication in details? How you have implemented in your project?

Authentication is verifying the identity of a user.  Authorization Is process where we check does this identity have access rights to the system. In short we can say the following authentication is the process of obtaining some sort of credentials from the users and using those credentials to verify the user’s identity.  Authorization is the process of allowing an authenticated user access to resources. Authentication always proceed to Authorization; even if your application lets anonymous users connect and use the application, it still authenticates them as being anonymous.

2) Explain page life-cycle? What’ is the sequence in which ASP.NET events are processed?

Processing steps. General Page Life-Cycle Stages: Page request, Start, Initialization, Load, Postback event handling, Rendering, Unload.

3) In which event are the controls fully loaded?

Page_load event guarantees that all controls are fully loaded. Controls are also accessed

in Page_Init events but you will see that viewstate is not fully loaded during this event.

4) How can we identify that the Page is PostBack ?

Page object has a “IsPostBack” property which can be checked to know that is the page posted back.

5) Where is ViewState information stored?

In HTML Hidden Fields

6) How can we create custom controls in ASP.NET ?

User controls are created using .ASCX in ASP.NET. After .ASCX file is created you need to two things in order that the ASCX can be used in project:

√ Register the ASCX control in page using the <%@ Register directive. Example

<%@ Register tagprefix=”Accounting” Tagname=”footer” Src=”Footer.ascx” %>

√ Now to use the above accounting footer in page you can use the below directive.

<Accounting:footer runat=”server” />

7) What is the difference between User Control and custom Server Controls?

User control

1.Compiled at runtime
2.HTML design (Visual design possible)
3.ASP.Net page model with code behind
4.Needs ASP.NET .aspx page to exist (can be used)
5.No design time interface
(Only a box representing the user control is available on an .aspx page)
6.Cannot be added to the ToolBox

Custom Server Control

1.Precompiled
2.No visual design. HTML needs to be declared programmatically
3.Component model
4.can be used in .aspx pages, user controls or other custom server controls.
5.Has design-time and run-time interface
6. Can be added to the ToolBox (using drag and drop)

 

8) Can you explain what is “AutoPostBack” feature in ASP.NET?

If we want the control to automatically postback in case of any event, we will need to check this attribute as true. Example on a ComboBox change we need to send the event immediately to the server side then set the “AutoPostBack” attribute to true.

9) What’s the use of “GLOBAL.ASAX” file?

It allows to executing ASP.NET application level events and setting application-level variables.

10) What is a SESSION and APPLICATION object?

Session object store information between HTTP requests for a particular user, while application object are global across users.

12) What is the difference between Server.Transfer and response.Redirect?

Major differences

Response.Redirect sends message to the browser telling it to move to a different page, while server.transfer does not send any message to the browser but rather redirects the user directly from the server itself. So in server.transfer there is no round trip while response.redirect has a round trip and hence puts a load on server.

Using Server.Transfer you cannot redirect to a different from the server itself.

Example if your server is www.yahoo.com you can use server.transfer to move to www.microsoft.com but yes you can move to www.yahoo.com/travels, i.e. within websites. This cross server redirect is possible only using

Response.redirect.

With server.transfer you can preserve your information. It has a parameter called as “preserveForm”. So the existing query string etc. will be able in the calling page.

If you are navigating within the same website use “Server.transfer” or else go for “response.redirect()”

12) What are the various authentication techniques in ASP.NET?

Selecting an authentication provider is as simple as making an entry in the web.config file for the application. You can use one of these entries to select the corresponding built in authentication provider:

√ <authentication mode=”windows”>

√ <authentication mode=”passport”>

√ <authentication mode=”forms”>

√ Custom authentication where you might install an ISAPI filter in IIS that compares incoming requests to list of source IP addresses, and considers requests to be authenticated if they come from an acceptable address. In that case, you would set the authentication mode to none to prevent any of the .net authentication providers from being triggered.

13) What’s difference between Datagrid, Datalist and repeater?

A Datagrid, Datalist and Repeater are all ASP.NET data Web controls.

They have many things in common like DataSource Property, DataBind Method

ItemDataBound and ItemCreated.

When you assign the DataSource Property of a Datagrid to a DataSet then each DataRow present in the DataRow Collection of DataTable is assigned to a corresponding DataGridItem and this is same for the rest of the two controls also. But The HTML code generated for a Datagrid has an HTML TABLE <ROW> element created for the particular DataRow and it’s a Table form representation with Columns and Rows.  For a Datalist its an Array of Rows and based on the Template Selected and the RepeatColumn Property value We can specify how many DataSource records should appear per HTML <table> row. In short in datagrid we have one record per row, but in datalist we can have five or six rows per row.

For a Repeater Control, the Datarecords to be displayed depends upon the Templates specified and the only HTML generated is the due to the Templates.  In addition to these, Datagrid has a in-built support for Sort, Filter and paging the Data, which is not possible when using a DataList and for a Repeater Control we would require

to write an explicit code to do paging.

14) From performance point of view how do they rate? Repeater is fastest followed by Datalist and finally datagrid.

15) What are major events in GLOBAL.ASAX file?

The Global.asax file, which is derived from the HttpApplication class, maintains a pool of HttpApplication objects, and assigns them to applications as needed. The Global.asax file contains the following events:

Application_Init: Fired when an application initializes or is first called. It is invoked for all HttpApplication object instances.

Application_Disposed: Fired just before an application is destroyed. This is the ideal location for cleaning up previously used resources.

Application_Error: Fired when an unhandled exception is encountered within the application.

Application_Start: Fired when the first instance of the HttpApplication class is created.

It allows you to create objects that are accessible by all HttpApplication instances.

Application_End: Fired when the last instance of an HttpApplication class is destroyed.

It is fired only once during an application’s lifetime.

Application_BeginRequest: Fired when an application request is received. It is the first event fired for a request, which is often a page request (URL) that a user enters.

Application_EndRequest: The last event fired for an application request.

Application_PreRequestHandlerExecute: Fired before the ASP.NET page framework begins executing an event handler like a page or Web service.

Application_PostRequestHandlerExecute: Fired when the ASP.NET page framework has finished executing an event handler.

Applcation_PreSendRequestHeaders: Fired before the ASP.NET page framework sends HTTP headers to a requesting client (browser).

Application_PreSendContent: Fired before the ASP.NET page framework send content to a requesting client (browser).

206

Application_AcquireRequestState: Fired when the ASP.NET page framework gets the current state (Session state) related to the current request.

Application_ReleaseRequestState: Fired when the ASP.NET page framework completes execution of all event handlers. This results in all state modules to save their current state data.

Application_ResolveRequestCache: Fired when the ASP.NET page framework completes an authorization request. It allows caching modules to serve the request from the cache, thus bypassing handler execution.

Application_UpdateRequestCache: Fired when the ASP.NET page framework completes handler execution to allow caching modules to store responses to be used to handle subsequent requests.

Application_AuthenticateRequest: Fired when the security module has established the current user’s identity as valid. At this point, the user’s credentials have been validated.

Application_AuthorizeRequest: Fired when the security module has verified that a user can access resources.

Session_Start: Fired when a new user visits the application Web site.

Session_End: Fired when a user’s session times out, ends, or they leave the application

Web site.

Note:  During interview you do not have to really cram all these events. But just keep the basic events in mind.

 

16) In What order are they triggered ?

They’re triggered in the following order:

Application_BeginRequest

Application_AuthenticateRequest

Application_AuthorizeRequest

Application_ResolveRequestCache

Application_AcquireRequestState

Application_PreRequestHandlerExecute

207

Application_PreSendRequestHeaders

Application_PreSendRequestContent

<<code is executed>>

Application_PostRequestHandlerExecute

Application_ReleaseRequestState

Application_UpdateRequestCache

Application_EndRequest.

.