ASP.NET

1.What is ASP.NET?
ASP means Active Server Page is a technology which provides set of specifications for creating web-based applications. It supports server side code execution. ASP.NET compiles the web pages and provides much better performance than sripting language such as VB script.

2.Differenct between ASP and ASP.NET?
The basic difference between ASP and ASP.NET is that ASP is interpreted where as ASP.NET is compiled. This implies that since ASP uses VBscript 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).

3.What is ASP.NET web form?
ASP.NET web forms are designed to use controls and features that are almost as powerful as the one 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.
 
4.What is IIS and why it is used?
IIS is a web server. Web server is software to manage web pages. This provides security for web pages. Browser and web server communication requires set of rules this is called Protocol. IIS 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 service of SMTP and FrontPage server extensions. The SMTP is used to send emails use FrontPage server extensions to get the dynamic features of the IIS.

5.What are the events that happened when a client request an ASP.NET page from IIS server.
The following events happened when a client requests an ASP.NET page from the IIS server :-
(i) User requests for an application resource.
(ii) The integrated request processing pipeline receives the first user request.
(iii) Response object are created for each user request.
(iv) An object of the HttpApplication class is created and allocated to the Request object.
(v) The HttpApplication class processes the user request.

6.What is the process of the server side application architecture?
In server side application when the client makes a request for a web page the request is send to the server. The server after getting the request runs the server side application and returns back the output as a response in the form of an HTML document.
  
7.What are the process of the client side application architecture?
In the client-side web application architecture when a user makes a request the request is send to the server. The server processes the request and sends back the response to the client. The client then runs the client-side application with the response provided by the server.

8.What is actually returned from server to the browser when a browser requests an .aspx file?
When a browser requests an .aspx  file then the server returns a response which is rendered into a HTML string.

9.What events are fired when a page loads?
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 post back 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.

10.Which event determines that all the controls are completely loaded into memory?
The Page_Load event determines that all the controls on the page are fully loaded. You can also access the controls in the Page_Init event however the ViewState property does not load completely during this event.

11.What is round trip?
The trip of a web page from the client to the server and then back to the client is known as a round trip.

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

13.What are web server control in ASP.NET?
The ASP.NET Web Server controls are objects on the ASP.NET pages that run when the web page is required. Many web server controls such as button and text box are similar to the HTML controls. In addition to the HTML controls there are many controls which include complex behavior such as the controls used to connect to data sources and display data.

14.What are custom user controls in ASP.NET?
The custom user controls are the controls that are defined by developers. These controls are a mixture of custom behavior and predefined behavior. These controls work similar to other web server controls.

15.What is state management? How many ways is there to mentain 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 that is Client-based state management and Server-based state management.
The following techniques can be used to implement the Client-Based state management

  • View State
  • Hidden Fields
  • Cookies
  • Query String
  • Control State
The following techniques can be used to implement Server-Based state management

  • Application State
  • Session State
  • Profile Properties

16.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 that is 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.

17.Which ASP.NET object encapsulate the state of the client and the browser?
The Session object encapsulates the state of the client and browser.
 
18.What is the behavior of a web browser when it receives an invalid element?
The behavior of a web browser when it receives an invalid element depends on the browser that you use to browse your application. Most of the browsers ignore the invalid element whereas some of them display the invalid element on the page.

19.Explain the validation controls. How many validation controls 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. ASP.NET contains 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 value.
  • RequireExpressionValidator - Ensures that input is according to the specified pattern or not.
  • RequireFieldValidator - Checks either a control is empty or not.
  • ValidationSummary - Displays a summary of all validation error in a central location.

20.Write 3 common properties of all validation control.
Three common properties of validation controls are as follows:

  • ControlToValidate - Provides a control to validate.
  • ErrorMessage - Displays an error message.
  • IsValid - Specifies if the controls validation has succeeded or not.
  • Text - Displays a text for validation control before validation

21.What is the function of the CustomValidator control?
It provides the customize validation code to perform both client-side and server-side validation.

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

23.Where is the ViewState information stored?
The ViewState information is stored in the HTML hidden fields.

24.What does the "EnableViewState" property do? Why do we want it ON or OFF?
The EnableViewState property enables the ViewState property on the page. It is set to on to allow the page to save the users input between postback requests of a web page that is between the Request and corresponding Response object. When this property is set to Off the page does not store the users input during postback.

25.What is the use of web.config?
ASP.NET configuration files are XML-based text file for application level setting and are saved with the name web.config. These files are present in multiple directories on an ASP.NET web application server. The web.config file sets the configuration setting to the directory it is placed in and to all the virtual sub
folders under it. The setting in sub directories can optionally override or change the setting specified in the base directory.

26.What is Role-based security?
In the Role-Based security you can assign a role to every user and grant the privilege according to that role. A role is a group of principal that restricts a user’s privilege. Therefore all the origination and applications use role-based security model to determine whether a user has enough privileges to perform a requested task.

27.What is the appSetting section in the web.config file?
The web.config file sets the configuration for a web project. The appSetting block in configuration file sets the user-defined values for the whole application.
For example in the following code snippet the specified ConnectionString section is used throughout the project for database connection
               
                <configuration>
                <appSettings>
                <add key="ConnectionString" Value="server=ajit;pwd=123;database=mydb"/>
                </appSettings>

28.What is the use of the <sessionState> tag in the web.config file?
The <sessionState> tag is used to configure the session state features. To change the default timeout which is 20 minutes, you have to add the following code snippet to the web.config file of an application.
                <sessionState timeout="40"/>

29.What is query string? What are the 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 String.
  • 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 threads.

30.What is 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 users request and the servers response.

31.How many types of cookies are available in ASP.NET?
There are two types of cookies available in ASP.NET that is

  • Session Cookie - Resides on the client machine for a single session until the user does not log out.
  • Persistent Cookie - Resides on the users machine for a period specified for its expiry, such as 10 days, one month and never. The user can set this period manually.

32.What is the default timeout for a cookie?
The default time duration for a Cookie is 30 minutes.

33.Explain how cookies work?
The server tells the browser to put some file 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.

34.What is the use of the Global.asax file? what are the event handlers included in Global.asax file?
The Global.aspx file executes application-level events and sets application-level variables. The Global.aspx file contains some of the following important event handlers:

  •  Application_Erroe
  •  Application_Start
  •  Application_End
  •  Session_Start
  •  Session_End

35.How can you dynamically add user controls to a page?
User controls can be dynamically loaded by adding Web User Control page in the application and adding the control on this page.

36.What is the difference between authentication and authorization?
Authentication verifies the identity of a user and authorization is a process where you can check whether or not the identity has access right to the system. In other words you can say the authentication is a procedure of getting some credentials from the users and verify the user's identity against those credentials. Authorization is a procedure of granting access of particular resources to an authenticated user. You should note that authentication always takes place before authorization.

37.How can you upload a file from an ASP.NET page?
The FileUpload control on ASP.NET is used to support the file uploading functionality. This control appears as a combination of the TextBox and the Button control and uploads a file from the clients system to the Web server. Users can click the button to browse in their local drives to select a file. To upload a file in ASP.NET you have to use two classes that is HtmlInputFile class and the HttpPostedFile class. The HtmlInputFile class provides an HTML input type control that the user uses to select a file to upload. The HttpPostedFile class provides the uploaded file. To use the HtmlInputFile control you must include the enctype attribute to your form tag as follows:
           
                   <form id="upload" method="post" runat="server" enctype="multipart / form-data">

38.How can you send an email message from an ASP.NET page?
You can use the System.Net.Mail.MailMessage and the System.Net.Mail.SmtpMail classes to send an email in your web page. 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.

39.Which page event checks the IsPostBack property during the page life cycle?

  • PreInit
  • Load
  • PreRender
  • LoadComplete
The PreInit event checks the IsPostBack during the page life cycle.

40.What is the difference between HTML and web server controls?
HTML controls are client-side controls therefore all the validations for HTML controls are performed at the client side. On the other hand Web server controls are server side controls therefore all the validations for web server controls are performed at the server side.

41.What is the difference between a Hyperlink control and a LinkButton?
A HyperLink control does not have the Click and Command events, whereas the LinkButton control has these events which can be handled in the code-behind file of the web page.

42.What does the orientation property do in a menu control?
Orientation property of the Menu control sets the horizontal or vertical display of a menu on a web page. By default the orientation is vertical.

43.Differenciate between client-side and server-side validations in web page.
Client-side validations takes place at the client end with the help of JavaScript and VbScript before the web page is send to the server. On the other hand server side validations take place at the server end.

44.Where should the data validations be performed and why?
Data validation 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 send a request to the server the validation controls are invoked to check the user input one by one.

45.How do you prevent a validation control from validating data at the client end?
You can prohibit a validation control to validate data at the client side by setting the EnableClientScript property to False.

46.what dose the .WebPart file do?
The .WebPart file explains the setting of a web parts control that can be included to a specified zone on a web page.

47.What setting must be added in the configuration file to deny a particular user form accessing the secured resource?
To deny a particular user from accessing the secured resources the web.config file must contain the following code:
                <authorization>
                <deny users = "username"/>
                </authorization>

48.Differenciate globalization and localization?
The globalization is a technique to identify the specific part of a web application that is different for different languages and make separate that portion from the core of the web application. The localization is a procedure of configuring a web application to be supported for a specific language or locale.

49.What do you understand by the culture?
The culture denotes a combination of a language and optionally a region or a country. The contents of a web page of a multilingual web site are changed according to the culture defined in the operating system of the user accessing the web page.

50.What is the difference between page level caching and fragment caching?
The page-level caching an entire web page is cached whereas in the fragment caching a part of the web page such as a user control added to the web page is cached.

51.Explain file-based dependency and key-based dependency.
In file-based dependency you have to depend on a file that is saved in a disk. In key-based dependency you have to depend on another cached item.

52.What do you understand by aggregate dependency?
Aggregate dependency allows multiple dependencies to be aggregated for content that depends on more than one resource. In such type of dependency you need to depend on the sum of all the defined dependencies to remove a data item from the cache.

53.What is the difference between ASP session and ASP.NET session?
ASP does not support cookie-less session whereas ASP.NET does. In addition the ASP.NET session can span across multiple servers.

54.Explain the cookie less session and its working.
ASP.NET manages the session state in the same process that processes the request and does not create a cookie. It is known as a cookie less session. If cookies are not available a session is tracked by adding a session identifier to the URL. The cookie less session is enabled using the following code snippet:
            
                                                   <sessionState cookieless = "true" />

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

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

57.why do you use the App_Code folder in ASP.NET?
The App_Code folder is automatically present in the project. It stores the file such as classes, typed data set, text files and reports. If this folder is not available in the application you can add this folder. One of the important features of the App_Code folder is that only one dll is created for the complete folder, irrespective of how many files it contains.

58.What do you mean by the web part controls in ASP.NET?
The web part controls are the integrated controls which are used to create a web site. These controls allow the users to change the content, outlook and state of web pages in a web browser.

59.What is ViewState?
The ViewState 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 ViewState to get the value of the control.

60.What is the function of the View State property?
The ASP.NET introduced a new property called ViewStateMode 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.

61.What is the lifespan for items stored in viewstate?
The items stored in ViewState live until the lifetime of the current page expires including the postbacks to the same page.

62.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 send in response.
  • Start - During this stage sets the Request and Response page property 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 controls 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 send to the client the page is unloaded.

63.What is the difference between the Response.Write() and Response.Output.Write() methods?
The Response.Write() method allows you to write the normal output whereas the Response.output.Write() method allows you to write the formatted output.

64.What is the use of PlaceHolder control?

The PlaceHolder control acts as a container for those controls that are dynamically generated at runtime. We cannot see it at runtime because it does not produce any visible output. it used only as a container.

No comments:

Post a Comment