Sunday, 16 March 2014

Interview Questions & Answers on Asp,Asp.Net and Web.Config in Asp.Net(Part 1)

  Asp,Asp.Net,Web.Config

1.What is ASP?

Ans:Active Server Pages (ASP), also known as Classic ASP, is a Microsoft's server-side technology, which helps in creating dynamic and user-friendly Web pages. It uses different scripting languages to create dynamic Web pages, which can be run on any type of browser. The Web pages are built by using either VBScript or JavaScript and these Web pages have access to the same services as Windows application, including ADO (ActiveX Data Objects) for database access, SMTP (Simple Mail Transfer Protocol) for e-mail, and the entire COM (Component Object Model) structure used in the Windows environment. ASP is implemented through a dynamic-link library (asp.dll) that is called by the IIS server when a Web page is requested from the server.

2.What is ASP.NET?

Ans:ASP.NET is a specification developed by Microsoft to create dynamic Web applications, Web sites, and Web services. It is a part of .NET Framework. You can create ASP.NET applications in most of the .NET compatible languages, such as Visual Basic, C#, and J#. The ASP.NET compiles the Web pages and provides much better performance than scripting languages, such as VBScript. The Web Forms support to create powerful forms-based Web pages. You can use ASP.NET Web server controls to create interactive Web applications. With the help of Web server controls, you can easily create a Web application.

3. What is the basic difference between ASP and ASP.NET?
Ans:The basic difference between ASP and ASP.NET is that ASP is interpreted; whereas, ASP.NET is compiled. This implies that since ASP uses Vb-script; therefore, when an ASP page is executed, it is interpreted. On the other hand, ASP.NET uses .NET languages, such as C# and VB.NET, which are compiled to Microsoft Intermediate Language (MSIL).

4.what is differences between classic asp and asp.net?

Ans:1.ASP is interpreted, ASP.NET is compiled.
2. Classic ASP uses a technology called ADO to connect and work with databases. ASP.NET uses the ADO.NET technology
3. ASP has Mixed HTML and coding logic where in asp.net html and coding part are separated by code behind files.
4. ASP.NET purely object oriented whereas ASP is partially object oriented.
5. For ASP No in-built support for XML whereas in ASP.NET full XML Support for easy data exchange.

5.can multiple versions of dotnet installed in the same machine?

Ans: yes, it is possible to install and run multiple versions of the MS.Net framework on the same machine.

6.What are the different stages in Page Life Cycle ?                                                        
Following are the different stages in Page Life Cycle                                
1)Start
2)Initialization
3)Load
4)Validation
5)Post back Event Handling
6)Rendering
7)Unload

6.What is the lifespan for items stored in ViewState?

Ans:The items stored inViewStatelive until the lifetime of the current page.

7.What are the advantages of the code-behind feature?
Ans:The code-behind feature of ASP.NET offers a number of advantages:

·      Makes code easy to understand and debug by separating application logic from HTML tags
·      Provides the isolation of effort between graphic designers and software engineers
·      Removes the problems of browser incompatibility by providing code files to exist on the Web server and supporting Web pages to be compiled on demand.

8.Which method is used to post a Web page to another Web page?

Ans:TheRespose.Redirectmethod is used to post a page to another page, as shown in the following code snippet:Response.Redirect("DestinationPageName.aspx");

9.How can you ensure that no one has tampered with ViewState in a Web page?

Ans:To ensure that no one has tampered with ViewState in a Web page, set the EnableViewStateMac property to True.

10.What are the major built-in objects in ASP.NET?

Ans:The major built-in objects in ASP.NET are as follows:

·      Application
·      Request
·      Response
·      Server
·      Session
·      Context
·      Trace

11.What is the appSettings Section in the web.config file?

Ans:The web.config file sets the configuration for a Web project. TheappSettingsblock in configuration file sets the user-defined values for the whole application.

For example, in the following code snippet, the specifiedConnectionStringsection is used throughout the project for database connection:

<configuration>
<appSettings>
<add key="ConnectionString" value="server=indiabixserver; pwd=dbpassword; database=indiabix" />
</appSettings>

12.What type of code, client-side or server-side, is found in a code-behind file of a Web page?

Ans: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.

13.Which event determines that all the controls are completely loaded into memory?

Ans:The Page_Load event determines that all the controls on the page are fully loaded. You can also access the controls in thePage_Initevent; however, theViewStateproperty does not load completely during this event.

14.Where is the ViewState information stored?

Ans:The ViewState information is stored in the HTML hidden fields.

15.What is the code-behind feature in ASP.NET?

Ans: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.csextension (if you are using the programming language C#) or the.vb(if you are using the programming language Visual Basic .NET) extension. 

16.What events are fired when a page loads?

Ans:The following events fire when a page loads:

·      Init()- Fires when the page is initializing.
·      LoadViewState()- Fires when the view state is loading.
·      LoadPostData()- Fires when the postback data is processing.
·      Load()- Fires when the page is loading.
·      PreRender()- Fires at the brief moment before the page is displayed to the user as HTML.
·      Unload()- Fires when the page is destroying the instances of server controls.

17.Which ASP.NET configuration options are supported in the ASP.NET implementation on the shared Web hosting platform?

Ans:There are many ASP.NET configuration choices, which are not able to configure at the site, application, or child directory level on the shared hosting environment. Some options can produce security, performance, and stability problem to the server and therefore cannot be changed. 

The following settings are the only ones that can be changed in the web.config file(s) of your Web site:

·      browserCaps
·      clientTarget
·      pages
·      customErrors
·      globalization
·      authorization
·      authentication
·      webControls
·      webServices

18.What are the different ways to send data across pages in ASP.NET?

Ans:The following two ways are used to send data across pages in ASP.NET:

·      Session
·      Public properties

19.What is Page_PreInit?

This event is the entry point to the page life cycle.  We can set the master pages and themes dynamically and also we can create the controls dynamically. We can check the IsPostBack Property to determine whether this is the first time the page is being processed or the page is a post back.


20.What is Page_Init?

This event fires after each control has been initialized. We can change the settings for the controls. We can change the initialization values of the controls in the page.

21.What is Page_InitComplete?

This event will be raised once all initializations of the page and its controls have been completed.

22.What is Page_PreLoad?

This event will load View state and Post data for all controls in a page.

23 What is timeout attribute in a forms element used for in web.config file?

Timeout attribute is used to set the number of minutes the authentication cookie persists on the user’s machine. The default is 30, indicating 30 minutes. ASP.NET renews the cookie automatically if it receives a request from the user and more than half of the allotted time has expired.

24.What happens when you make changes to an application’s Web.config file?

When you make changes to an application’s Web.config file, IIS automatically restarts the application and applies the changes. This has the side effect of resetting current Application or Session state variables, which can adversely affect users.

25What is Page_Load?

 This is the most familiar event for the developers. This method is typically used for most code, since it is the first place in the page life cycle that all the values are restored and the page has been restored to its previous state in case of postbacks. We can check the IsPostback property to avoid unnecessary resetting state.

Syntax:

protected void Page_Load(object sender, EventArgs e)
{
}.


26.What is Control Events?

This might be a button’s click event or a dropdown's selectedindexchange event.

Syntax:

protected void Button1_Click(object sender, EventArgs e)
{
}

27.What is Page_LoadComplete?

This event signals the end of Load.

Syntax:

protected void Page_LoadComplete(object sender, EventArgs e)
{
}

28.What is AppDomain ?
                                                                              
  In .NET facility is provided to create logical partitions inside the process      and these partitions is called as AppDomain. A single process can have one or more AppDomain.

29.Is AppDomain created with every request ?

Ans:No AppDomain is not created with every request .It is created only for the first request and later on it is reused.


30.What is web.config file in asp.net?

Ans: Web.config is the main settings and configuration file for an ASP.NET web application. The file is an XML document that defines configuration information regarding the web application. The web.config file contains information that control module loading, security configuration, session state configuration, and application language and compilation settings. Web.config files can also contain application specific items such as database connection strings.

31.What are the 3 levels at which we can have a configuration file for an ASP.NET web application?

At the web server level : The Machine.config file located in the Windows\Microsoft.NET\Framework\version\config directory. This sets the base configuration for all .NET assemblies running on the server.

At the application or web site level : The Web.config file located in the IIS root directory.This sets the base configuration for all Web applications and overrides settings in Machine.config.


In the sub directory of an application root folder : These settings override the settings in the root folder's web.config file.


32.What happens when you make changes to an application’s Web.config file?


  When you make changes to an application’s Web.config file, IIS automatically restarts the application and applies the changes. This has the side effect of resetting current Application or Session state variables, which can adversely affect users.


33.What happens when you access the Web.config file from a browser?

  For security reasons, you can’t access the Web.config file from a browser. If a user requests the Web.config file from your Web site, he or she will receive an "This type of page is not served" error message.


34.What happens when someone accesses a Web application that uses Forms authentication?

Ans:When someone accesses a Web application that uses Forms authentication, ASP.NET displays the log on Web form specified in Web.config. Once a user is authorized, ASP.NET issues an authorization certificate in the form of a cookie that persists for an amount of time specified by the authentication settings in Web.config.

35.What is the use of mode attribute in authentication element in a web.config file?

Ans:You use the mode attribute to specify the type of authentication your web application is using. Set the mode attribute to forms to enable Forms authentication.

36.What is the use of name attribute and loginUrl attribute of a forms element in a web.config file?

Ans: Name attribute of forms element is used to set the name of the cookie in which to store the user’s credential. The default is .authaspx. If more than one application on the server is using Forms authentication, you need to specify a unique cookie name for each application.

Log in URL attribute of forms element is used to set the name of the Web form to display if the user has not already been authenticated. If omitted, the default is Default.aspx.

37.What is protection attribute in a forms element used for in web.config file?

Ans: The protection attribute of a forms element of web.config file is used for setting how ASP.NET protects the authentication cookie stored on the user’s machine. The default is All, which performs encryption and data validation. Other possible settings are Encryption, Validation, and None.

39.Which method checks the user name and password against the user list found in the credentials element of Web.config?

Ans:The Forms Authentication class’s Authenticate method checks the user name and password against the user list found in the credentials element of Web.config.

40.Can you change authentication type in a subfolder's web.config file?

Ans:Authentication type (Windows, Forms, or Passport) can be set only at the application’s root folder. To change authentication type in a subfolder's web.config file, you must create a new Web application project and application starting point for that sub folder.

41.Can We Delete Our Web.Config file?

Ans:Yes,we can delete Web.Config file.Even though you deleted your Web.Config file,at run time it will generate automatically.

42.Which is the parent class of the Web server control?

Ans:The System.Web.Ul.Control class is the parent class for all Web server controls.

43.What is AutoPostBack?

Ans:If you want a control to postback automatically when an event is raised, you need to set the AutoPostBackproperty of the control to True.

44.Which two new properties are added in ASP.NET 4.0 Page class?

Ans:The two new properties added in the Page class are MetaKeyword and MetaDescription.

45.Can we run asp.net application without WEB.CONFIG file ?

Ans:Yes, we can run an asp.net application without the WEB.CONFIG file. It means that the default configuration will be loaded from MACHINE.CONFIG file.

46.What type of code, client-side or server-side, is found in a code-behind file of a Web page?

Ans: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.







No comments:

Post a Comment