Pages

Wednesday 31 December 2014

Important Interview Tips in ASP.NET



Important Interview Tips in ASP.NET


1. Explain page directives?


The first line of an Asp.Net page is the page directive; you can see it on all Asp.Net pages. These directives are instructions for the page. It starts with the @Page directive and continues with the different attributes available to this directive list.

The basic syntax for a Page directive is:


<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
The attributes of the Page directive are:

Title

Specifies a title for the page that is rendered within the HTML <title> tags in the response. The title can also be accessed programmatically as a property of the page.

Language

Specifies the language used when compiling all inline rendering (<% %> and <%= %>) and code declaration blocks within the page, From  VB.net, C#.net, Jscript  only one language can be used  per page.

MasterPageFile

Sets the path to the master page for the content page or nested master page

AutoEventWireup

Indicates whether the page's events are autowired. true if event autowiring is enabled; otherwise, false.

CodeBehind  name of the code behind file

Inherits     the name of the code behind or other class

2. Hyperlink Vs LinkButton in ASP.NET?

A Hyperlink just redirects to a given URL identified by “NavigateURL” property. LinkButton which actually displays a Hyperlink style button causes a postback to the same page but it doesn’t redirect to a given URL.

3. Label Control Vs Literal Control in ASP.NET?

A Label control in ASP.NET renders text inside <span> tags while a Literal Control renders just the text without any tags.
With Label controls we can easily apply styles using it’s CssClass property, however, if we don’t want to apply style/formatting, it’s better to go for a Literal control.

4. Difference between WCF and ASMX Web Services?

Web service is designed to send and receive messages using SOAP over HTTP only. While WCF can exchange messages using any format (SOAP is default) over any transport protocol (HTTP, TCP/IP, MSMQ, NamedPipes etc.
Web Services                                     WCF
Hosted in IIS only                               Hosted in IIS, WAS, Console, WinNT Services, WCF provided
Host Support for HTTP only              Support for HTTP, TCP, MSMQ, Named Pipes
Limited Security                                 A consistent security Programming Model
Uses XMSerializer                             uses DataContractSerializer

5. Custom controls Vs User controls in ASP.NET?


Custom controls are basically compiled code i.e. DLLs. These can be easily added to toolbox, so it can be easily used across multiple projects using drag and drop approach. These controls are comparatively hard to create.

User Controls (.ascx) are just like pages (.aspx). These are comparatively easy to create but tightly couple with respect to User Interface and code. In order to use across multiple projects, we need to copy and paste to the other project as well.

6. Difference between a Postback and a Callback in ASP.NET?

A postback is a request sent from a client to server from the same page, user is already working with.
A callback is generally a call for execution of a function after another function has completed.


7. Explain Global.asax in ASP.NET?

Global.asax is basically ASP.NET Application file. It’s a place to write code for Application-level events such as Application start, Application end, Session start , Session end, Application error, Application begin request,, Application end request etc.

8. Can we Enable/Disable ViewState?

Yes, ViewState can be enabled or disable at different levels:
Control Level ViewState for a specific control can be enabled or disabled by setting  EnableViewState property
         aControl.EnableViewState = false;
Page Level we can enable/disable ViewState for a complete page
            <%@ Page Language=”C#” EnableViewState=”false” %>
Application Level For whole application, we can enable/disable views in configuration file
<pages enableViewState=”false”>
    ….
</pages>

9. Difference between Globalization Vs Localization

When we need to create an application that work for multiple cultures e.g en-US, ar-SAetc, the process of designing and building applications that work on more than one cultures is called globalization. However, customizing an application for a specific culture is localization.

10. Session.Clear() Vs Session.Abandon() in ASP.NET?

Session.Clear() clears all the session values but doesn’t destroy the Session.
Session.Clear() is like deleting all files inside a folder (say “Root”)

 Session.Abandon() destroys the session object.
Session.Abandon() means deleting the “Root” folder.

--------------------------------------------------------------------------------------------------------

For more details:
Sakthi Software Solutions Pvt Ltd,
RVR Towers, 4th Floor, No.1, AA Block,
1st Street, 3rd Main Road,
Annanagar, Chennai 600 040.
Landmark: Annanagar Roundtana,
Behind Nalli Silks Showroom,
Contact: 9840533344, Email: contactus@sssedu.in
website: www.sssedu.in

No comments:

Post a Comment