Friday, 24 November 2017

ASP.NET INTERVIEW QUESTIONS PART-1

1) What is ASP?
ASP - Active Server Page.
Active: - Active means, an asp page provides dynamic content that are updated every time,
When it is Accessed (run).
Server: - An asp.net page contains scripts codes that always Executes on web server.
Page: - An asp page is a web page that display in browser when any user execute it and navigate to another web page.
        
2) What is difference between ASP and ASP.NET?      
Difference between Asp and Asp.Net:-
1. Asp program is interpreted but Asp.Net program is compiled.
2. In Asp we can use only scripting language to provide dynamic functionality but in Asp.Net we can use programming language to provide dynamic functionality.
3. In Asp there is only one file in form where everything related to design and business logic is specified. But in Asp.Net we have two file, one is to specify the design code and second is to specify business logic code.
4. Asp runs only Microsoft platforms but Asp.Net runs Microsoft platforms as well as Non Microsoft platforms also. CASSINI is a simple web server produced by Microsoft which is used to host Asp.net Application.
5. Asp was very difficult for us debug the application because it is used interpreted model. But Asp.Net was easily for us to debug the application because it is used compiled model.

3) What are the advantages of ASP.NET?                                                                              
1. It is used to develop simpler and easier applications.
2. It is used to develop dynamic application using c#.
3. It provides security to the asp.net applications such as Windows authentication, Passport     authentication, Form based authentication etc.
4. It is easily manage two files such as Design Form, Logic file or code file in any asp.net application.
5. It provides Built-in caching features also.

4) What is IIS? Why is it used?
Internet Information Services (IIS) is created by Microsoft to provide Internet-based services to ASP.NET Web applications. It makes your computer to work as a Web server and provides the functionality to develop and deploy Web applications on the server. IIS handles the request and response cycle on the Web server. It also offers the services of SMTP and FrontPage server extensions. The SMTP is used to send emails and use FrontPage server extensions to get the dynamic features of IIS, such as form handler.

5) What are the events that happen when a client requests an ASP.NET page from IIS server?
The following events happen when a client requests an ASP.NET page from the IIS server:
1. User requests for an application resource.
2. The integrated request-processing pipeline receives the first user request.
3. Response objects are created for each user request.
4. An object of the HttpApplication class is created and allocated to the Request object.
5. The HttpApplication class processes the user request.

6) Describe the complete lifecycle of a Web page.
When we execute a Web page, it passes from the following stages, which are collectively known as Web page lifecycle:
      Page request - During this stage, ASP.NET makes sure the page either parsed or compiled
and a cached version of the page can be sent in response.
     Start - During this stage sets the Request and Response page properties and the page check the page request is either a postback or a new request
      Page Initialization - During this stage, the page initialize and the control's Unique Id property are set
      Load - During this stage, if the request is postback, the control properties are loaded without loading the view state and control state otherwise loads the view state
Validation - During this stage, the controls are validated
Postback event handling - During this stage, if the request is a postback, handles the event
Rendering - During this stage, the page invokes the Render method to each control for return the output
Unload - During this stage, when the page is completely rendered and sent to the client, the page is unloaded.

7) 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 view state is not fully loaded during this event

8) How can you implement the postback property of an ASP.NET control?
You need to set the AutoPostBack property to True to implement the PostBack property of controls.

9) What is AutoPostBack?
If you want a control to postback automatically when an event is raised, you need to set the AutoPostBack property of the control to True.

10) How can you identify that the page is PostBack?
The Page object uses the “IsPostBack” property to check whether the page is posted back or not. If the page is postback, this property is set to true.

11) What are three important files used in ASP.NET?                                                      
1. Machine.config
2. Web.config
3. Global.asax

12) What are the defaults Name space used on every ASP.NET page?
 Using System;
 Using System.IO;
 Using System.Web;
 Using System.Web.UI;
 Using System.Web.UI.WebControls;

13) What Namespace are used for Data Access in ASP.NET?
1. System.Data
2. System.Data.OledB
3. System.Data.SqlClient

14) What is .NET Remoting?                                                                                              
DOM Model is used for this functionality but .NET Remoting is replacement of DCOM Model .Web services, WCF and others are used this functionality.

15) What is the difference between Web Services and Remoting Services?
Web Services:- 
1. Web Services can be accessed only HTTP.
2. It works in a stateless environment.
3. It support interoperability across platforms and are ideal for heterogeneous environments.
4. It is easy to create and deploy.
5. It provides extensibility by allowing us to intercept the SOAP messages during the serialization and deserialization stages.
6. It is highly reliable because it can easily host on IIS Server.
7. It supports only the data type defined in the XSD type system.

.NET Remoting:- 
1. Remoting services can be accessed over any protocol (eg. TCP, HTTP, SMTP etc.)
2. It provides support for both stateful and stateless environments through singleton and single call objects.
3. It requires the client be built using .NET, enforcing homogenous environment.
4. It is complex to create and deploy.
5. It is very extensible by allowing customizing the different components of the .NET remoting framework.
6. It is less reliable with IIS Server.
7. With the help of binary communication .NET Remoting can provide support for rich type system.

 16) What is an ASP.NET Web Form?
ASP.NET Web forms are designed to use controls and features that are almost as powerful as the ones used with Windows forms, and so they are called as Web forms. The Web form uses a server-side object model that allows you to create functional controls, which are executed on the server and are rendered as HTML on the client. The attribute, runat="server", associated with a server control indicates that the Web form must be processed on the server.

17) What is Authentication and Authorization in ASP.NET?
Authentication:-Authentication is a process in which user can verify your credentials such as Id and password.
Authorization: - An Authorization is the process in which, Developers provides a specific roles to a specific user. Authorization process comes after the Authentication process.

18) What types of Authentication process is used in ASP.NET?                                    
1.      Windows authentication
2.      Forms based authentication
3.      Passport authentication
4.      Custom Authentication

19) What are the various ways of Authentication techniques in ASP.NET?
There are various techniques in ASP.NET to authenticate a user. You can use one of the following ways of authentication to select a built-in authentication provider:
      Windows Authentication - This mode works as the default authentication technique. It can work with any form of Microsoft Internet Information Services (IIS) authentication, such as Basic, Integrated Windows authentication (NTLM/Kerberos), Digest, and certificates. The syntax of Windows authentication mode is given as follows: <authentication mode="windows" />
     Forms Authentication - You can specify this mode as a default authentication mode by using the following code snippet: <authentication mode="Forms"/>
     Passport - This mode works with Microsoft Passport authentication, as shown in the following code snippet :< authentication mode = "Passport"/>

20) What is the code-behind feature in ASP.NET?
The code-behind feature of ASP.NET enables you to divide an ASP.NET page into two files - one consisting of the presentation data, and the second, which is also called the code-behind file, consisting of all the business logic. The presentation data contains the interface elements, such as HTML controls and Web server controls, and the code-behind contains the event-handling process to handle the events that are fired by these controls. The file that contains the presentation data has the .aspx extension. The code behind file has either the .cs extension (if you are using the programming language C#) or the .vb (if you are using the programming language Visual Basic .NET) extension.

21) What type of code, Client-Side or Server-Side, is found in a Code-behind file of a Web page?
A code-behind file contains the server-side code, which means that the code contained in a code-behind file is executed at the server.

22) What is difference between ASP Session and ASP.NET Session?       
ASP does not support cookie-less sessions; whereas, ASP.NET does. In addition, the ASP.NET session can span across multiple servers.       
ASP.NET session supports cookie less session and it can change 'span' tag on the server side at run time. ASP session is not like that.

23) What is difference between server side and client side code scripting in asp.net?   
Client side code is executed on the client side or Browser side (ex. check validation, clock    etc.)
    Server side code is executed on the server end (IIS, Other)

24) What is web user control in ASP.NET?                                                                            
Web user control is a set of control which can be used more than one web page. We can specify that set of control in form of web user control. We can easily change the value of a
Control specify in the web user control on the page.
Ex. you can change user control values when any user redirect to another web page like this:-
Protected void Page_Load
{
((Lable)Webusercontrol 1 .find("Label1")).Text = "Hello";
}

25) What are the different types of Validation Controls used in ASP.NET? 
Validation controls are responsible to validate the data of an input control. Whenever you provide any input to an application, it performs the validation and displays an error message to user in case the validation fails.
The following six types of validation controls:
CompareValidator - Performs a comparison between the values contained in two controls.
CustomValidator - Writes your own method to perform extra validation.
RangeValidator- Checks value according to the range of value.
RegularExpressionValidator - Ensures that input is according to the specified pattern or not.
RequiredFieldValidator - Checks either a control is empty or not.
ValidationSummary - Displays a summary of all validation error in a central location.

26) Where should the Data Validations be performed-at the Client Side or at the Server Side and why?
Data validations should be done primarily at the client side and the server-side validation should be avoided because it makes server task overloaded. If the client-side validation is not available, you can use server-side validation. When a user sends a request to the server, the validation controls are invoked to check the user input one by one.

27) What is the function of the Custom Validator Control?
It provides the customize validation code to perform both client-side and server-side validation.

28) Which method is used to force all the validation controls to run?
The Page.Validate() method is used to force all the validation controls to run and to perform validation.

29) What is Master page in asp.net?                                                                                      
If there is such a content which will remain same on top, Bottom, Left, Right Portion of more than web pages. We can specify those contents in form of Master page. We can use more than one master page in an application. We can use Nested master page in an application also. 

30) What is the use of Content Place Holder in Master Page?
This acts as a place where every page will specify its own contents. The extension of master page is .master.

31) Can we Run Master Page independently in ASP.NET?
We can't run master page independently in asp.net.

32) What is difference between master page and web user control in asp.net? 
Master Page:-
1. It uses extension .Master.
2. It is used like a template.
3. It contains content Content Place Holder.
Web User Control:-
1. It uses extension .ascx
2. It can be more than one of a single web page
3. It does not contain any Content Place Holder.
4. It does not work like a fixed template. It can be display in different manner in different pages.

33) Which is used mostly in real life, master page or web user control?                 
Both techniques are goods on your place but Master page is using mostly in our asp.net real application.

34) What is the purpose to use Global.asax file in ASP.NET?
Global.asax file is used to maintain session and application specific event within an application. We can have only one Global.asax file in an asp.net application.

35) What are the event handlers that can be included in the Global.asax file?
The Global.asax file contains some of the following important event handlers:
ü  Application_Error
ü  Application_Start
ü  Application_End
ü  Session_Start
ü  Session_End

36) What is State Management? How many ways are there to maintain a state in .NET?
State management is used to store information requests. The state management is used to trace the information or data that affect the state of the applications.
There are two ways to maintain a state in .NET, Client-Based state management and Server-
Based State Management.
The following techniques can be used to implement the Client-Based state management:
1)      View State
2)      Control State
3)      Hidden Fields
4)      Cookies
5)      Query Strings
The following techniques can be used to implement Server-Based state management:
1)      Application State
2)      Session State
3)      Profile Properties

37) What is View State?
The View State is a feature used by ASP.NET Web page to store the value of a page and its controls just before posting the page. Once the page is posted, the first task by the page processing is to restore the View State to get the values of the controls.

38) What is View state and how to implement it in ASP.NET Application?
View state stores page-specific information, when a page post back to the server. I have already implemented View state features in asp.net application.

39) What is the function of the View State property?
The ASP.NET 4.0 introduced a new property called View State Mode for the Control class. Now you can enable the view state to an individual control even if the view state for an ASP.NET page is disabled.

40) Where is the View State information stored?
The ViewState information is stored in the HTML hidden fields.

41) What is the lifespan for items stored in View State?
The items stored in View State live until the lifetime of the current page expires including the postbacks to the same page.

42) What is Hidden field control in ASP.NET Application?
If the web page view state is completely disabled but still we want to maintain some information for the current page. Then we generally use Hidden field control.

43) What is Session State in ASP.NET Application?
Session state is used to store the information at the server end. Whenever we access the web application, session id 128,256 or 512 bit generated. It depends which algorithm web are using.

44) What is Cookie in ASP.NET Application?
Cookie is a small text file which can be used to store the user specific information for personalized the web pages. It stores the data at the user end not server side.

45) What is a Cookie? Where is it used in ASP.NET?
Cookie is a lightweight executable program, which the server posts to client machines. Cookies store the identity of a user at the first visit of the Web site and validate them later on the next visits for their authenticity. The values of a cookie can be transferred between the user's request and the server's response.

46) What are different types of cookies used in ASP.NET?
There are two types of Cookies available in ASP.NET:
 Session Cookie - Resides on the client machine for a single session until the user does not log out.
Persistent Cookie - Resides on a user's machine for a period specified for its expiry, such as 10 days, one month, and never. The user can set this period manually.

47) Explain how Cookies work. Give an example of Cookie abuse?
The server tells the browser to put some files in a cookie, and the client then sends all the cookies for the domain in each request. An example of cookie abuse is large cookies affecting the network traffic.

48) What is Query String? What are its advantages and limitations?
The Query String helps in sending the page information to the server.
The Query String has the following advantages:
Every browser works with Query Strings.
It does not require server resources and so does not exert any kind of burden on the server.
The following are the limitations of Query String:
Information must be within the limit because URL does not support many characters.
Information is clearly visible to the user, which leads to security threats.

49) Why we use Query String in ASP.NET Application?
Query string is a method that stores the state information on the client end if we want to send some information from the previous page to Next page then we use Query strings in asp.net application. In this we can send the information as the Bar of URL by specifying'?'.

50) What is cross-page posting in ASP.NET?
The Server.Transfer() method is used to post data from one page to another. In this case, the URL remains the same. However, in cross page posting, data is collected from different Web pages and is displayed on a single page. To do so, you need to set the PostBackUrl property of the control, which specifies the target page. In the target page, you can access the PreviousPage property. For this, you need to use the @PreviousPageType directive. You can access the controls of previous page by using the Find Control () method.

51) How can you send an Email Message from an ASP.NET Web page?
You can use “System.Net.Mail.MailMessage” and the “System.Net.Mail.SmtpMail” class to send an classes to send an email in your Web pages. In order to send an email through your mail server, you need to create an object of the SmtpClient class and set the server name, port, and credentials.


No comments: