Asp .Net Interview Question and Answer | Web Application | Session 12

111. What is the use of Global.asax File in ASP.NET Application ? 
Ans: The Global.asax file, can be stored in root directory and accesible for web-sites,is an optional file.This Global.asax file contained in HttpApplicationClass.we can declare global variables like variables used in master pages because these variables can be used for different pages right.Importent feature is that its provides more security in comparision to other.
It handle two event:
        1.Application-level 
        2.Session-level events.

Global.asax File itself configured but it can not be accessed.while one request is in processing it is impossible to send another request, we can not get response for other request and even we can not start a new session.
while adding this Global.asax file to our application by default it contains five methods,
Those methods are:
        1. Application_Start.
        2. Application_End.
        3. Session_Start.
        4. Session_End.
        5. Application_Error.

112.  What is the Default Expiration Period For Session and Cookies,and maximum size of viewstate? 
Ans:  The default Expiration Period for Session is 20 minutes.
           The default Expiration Period for Cookie is 30 minutes.
            The maximum size of the viewstate is 25% of the page size
 
113. Difference between Session object and Profile object in ASP.NET? 
Ans:  
Profile object:
         1. Profile object is persistent.
         2. Its uses the provider model to store information.
         3. Strongly typed
         4. Anonymous users used mostly.
Session object:
         1. Session object is non-persistant.
         2. Session object uses the In Proc, Out Of Process or SQL Server Mode to store information.
         3. Not strongly typed.
         4. Only allowed for authenticated users.
 
114. Why the exception handling is important for an application? 
Ans: Exception handling prevents the unusual error in the asp.net application,when apllication executed.If the exceptions are handled properly, the application will never get terminated abruptly.

115. Define Error Events in Asp.Net?

Ans: In ASP.Net when any unhandled exception accurs in application then an event occures,that event called Error event.
Two types of Event:
          1. Page_Error:When exception occures in a page then this event raised.
          2. Application_error:Application_Error event raised when unhandled exceptions in the ASP.NET application and is implemented in global.asax.
          The error event have two method:
          1. GetLastError: Returns the last exception that occurred on the server.
          2. ClearError: This method clear error and thus stop the error to trigger subsequent error event.

116. How to create Multivalued Cookie ?
 
Ans:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

    void btnSubmit_Click(Object s, EventArgs e)
    {
        Response.Cookies["preferences"]["firstName"] = txtFirstName.Text;
        Response.Cookies["preferences"]["lastName"] = txtLastName.Text;
        Response.Cookies["preferences"]["favoriteColor"] = txtFavoriteColor.Text;
        Response.Cookies["preferences"].Expires = DateTime.MaxValue;
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Set Cookie Values</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <asp:Label
        id="lblFirstName"
        Text="First Name:"
        AssociatedControlID="txtFirstName"
        Runat="server" />
    <br />
    <asp:TextBox
        id="txtFirstName"
        Runat="server" />
    <br /><br />
    <asp:Label
        id="lblLastName"
        Text="Last Name:"
        AssociatedControlID="txtFirstName"
        Runat="server" />
    <br />
    <asp:TextBox
        id="txtLastName"
        Runat="server" />
    <br /><br />
    <asp:Label
        id="lblFavoriteColor"
        Text="Favorite Color:"
        AssociatedControlID="txtFavoriteColor"
        Runat="server" />
    <br />
    <asp:TextBox
        id="txtFavoriteColor"
        Runat="server" />
    <br /><br />
    <asp:Button
        id="btnSubmit"
        Text="Submit"
        OnClick="btnSubmit_Click"
        Runat="server" />
    </div>
    </form>
</body>
</html>
 
117. How do you require authentication using the Web.config file? 
 Ans: Include the following:
<authorization>
  <deny users="?">
</authorization>
118. What is the difference between web.config and Machine.config files? 
Ans: 1. Machine.config is a system lebel configaration. Where as web.config, it is applicable to only one application, i.e., each asp.net webapplication will contain at least one web.config file.
          2. Web.config file settings will override machine.config settings.
          3. Machine.config file specifies configuration settings for all of the websites on the web server.Web.config file

specify configuration settings for a particular web application, and is located in the applications root directory .
 
119. What is the main difference between the Button server control and the Button HTML control?   
Ans: The Button HTML control triggers the event procedure indicated in the button’s onclick attribute, which runs on the client.
         When clicked, the Button server control triggers an ASP.NET Click event procedure on the server.


120. Differences between Web and Windows applications?
Ans:  Windows Forms:Windows forms are instantiated, exist for as long as needed, and are destroyed. Windows applications run on the same machine they are displayed on.Windows applications display their own windows and have more control over how those windows are displayed.

Web Forms:Web forms use server controls, HTML controls, user controls, or custom controls created specially for Web forms.Web applications are displayed in a browser.Web forms are instantiated on the server, sent to the browser, and destroyed immediately.
 


Previous Next


:: Click the links below for similar type Questions and answers ::

0 comments:

Post a Comment

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes