Sunday, 16 March 2014

Interview Questions & Answers On Asp,Asp.Net and Web.Confing in ASP.NET(Part 2)

Faq’s On ASP:

1.What is Active Server Pages?
Microsoft  Active Server Pages (ASP) is the server-side execution environment in Microsoft Internet Information Server (IIS) 3.0 that enables you to run ActiveX scripts and ActiveX server components on the server. By combining scripts and components, developers can create dynamic content and powerful Web-based applications easily.

2. What is dynamic content?
Web pages that are customized for each user  based upon their actions or requests. For example, new visitors to your site can be shown a different welcome page  or pages in an online catalog can be queries to a database so customers always see the most current information and availability.

3. Who should use Active Server Pages?
Organizations will use the Active Server Pages technology to put a Web front end on existing business solutions, or to create entirely new Web-based applications. Since ASP provides a very open development environment, with support for both Microsoft Visual Basic, Scripting Edition (Vb-script) and J script  organizations can leverage the investments they already have in these scripting languages.

4. Who can create dynamic content with Active Server Pages?
Webmasters, information systems (IS) professionals, and programmers familiar with Hypertext Markup Language (HTML) and languages such as Microsoft Visual Basic, JavaScript, PERL, REXX, or C++.

5. What do I need to run Active Server Pages?
The Active Server Pages feature of IIS 3.0 requires at least Microsoft Windows NT  Server 4.0 running IIS 2.0 or Windows NT Workstation 4.0 running Peer Web Services.

6. How much will Active Server Pages cost?
Active Server Pages is a component of IIS 3.0, which is a free, download able, and integrated feature of Windows NT Server 4.0.

7. What are the advantages of using ASP?
HTML is used only to create static web pages (which displays information) With the use of ASP one can create dynamic web pages,where client can communicate with the web server and vice versa. Thus using ASP interactive web-pages can be created.
8.How to handle Error in ASP?
Using On Error Resume Next information about the server.
9. What is the basic difference between ASP and ASP.NET?
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).
Page Life Cycle:

1.Explain the life cycle of an ASP .NET page.?
Following are the events occur during ASP.NET Page Life Cycle:
1)Page_PreInit
2)Page_Init
3)Page_InitComplete
4)Page_PreLoad
5)Page_Load
6)Control Events
7)Page_Load complete
8)Page_PreRender
9)SaveViewState
10)Page_Render
11)Page_Unload
Among above events Page_Render is the only event which is raised by page. So we can't write code for this event.

2.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

3. What is the use of AutoEventWireup in asp.net?
 If AutoEventWireup is set to true then asp.net will look for methods with specific name and if that method found it automatically calls that method when specific event occurs. For ex If we follow the convention such as Page_event then that method gets automatically called eg Page_PreInit,Page_Init.


4.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.

5.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.

6.What is Page_InitComplete?
This event will be raised once all initializations of the page and its controls have been completed.

7.What is Page_PreLoad?
This event will load View state and Post data for all controls in a page.

8.What is LoadViewState?
Viewstate information is saved as a string of name/value pairs and contains information such as control text or value. The viewstate is held in the value property of a hidden <input> control that is passed from page request to page request.

9.What is LoadPostData?
Post Data is nothing but the changed values of control. Suppose if we have a text box control which contains the customer name “Smith”, if you change the customer name to “Smith123”,this changed value is loaded in this LoadPostdata.

10.What 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)
{
}

11.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)
{
}

12.What is Page_LoadComplete?
This event signals the end of Load.

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

13.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.

14.Is AppDomain created with every request ?
No AppDomain is not created with every request .It is created only for the first request and later on it is reused.

15.       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.

Web.config:

1.What is web.config file in asp.net?
 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.

2.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.


3.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.


4.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.


5.What happens when someone accesses a Web application that uses Forms authentication?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.

6.What is the use of mode attribute in authentication element in a web.config file?
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.

7.What is the use of name attribute and loginUrl attribute of a forms element in a web.config file?
 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.

8.What is protection attribute in a forms element used for in web.config file?
 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.

9.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.

10.Which method checks the user name and password against the user list found in the credentials element of Web.config?
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.

11.Can you change authentication type in a subfolder's web.config file?
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.

12.Can We Delete Our Web.Config file?
Yes,we can delete Web.Config file.Even though you deleted your Web.Config file,at run time it will generate automatically.

No comments:

Post a Comment