2016-06-16

ASP.NET INTERVIEW QUESTION ANSWERS.

1. Define Exception handling in ASP.NET.

Answer: Exceptions or errors are unusual occurrences that happen within the logic of an application. The CLR has provided structured way to deal with exceptions using Try/Catch block. ASP.NET also supportsexceptionhandling through server events such as Page_Error and Application_Error events.

2. What are navigation controls? How many navigation controls are there in ASP.NET .?

Answer: Navigation controls help you to navigate in a Web application easily. These controls store all the links in a hierarchical or drop-down structure; thereby facilitating easy navigation in a Web application. There are three navigation controls in ASP.Net 4.0. • SiteMapPath • Menu • TreeView

3. What is the authentication mode available in ASP.NET?

Answer: ASP.NET supports three authentication modes through the System.Web.Security namespace. Windows Authentication The windows authentication authenticates users based on their windows accounts. In short, it uses windows network security. It uses IIS to perform authentication. Passport authentication The Passport authentication uses Microsoft's passport service to authenticate users. The new user is directed to the Microsoft site where he can register his identity. This facilitates user to access multiple sites using single user name and password. You need to install the Passport SDK to enable the Passport classes in the System.Web.Security namespace. Form authentication The Form authentication collects user's credential and lets the application use own logic to authenticate users. The collected user's credential is validated using the list maintained by the application. The application maintains its own user list either using <credential>element in the web.config file or using database. The advantage of using form authentication is that the users don't need to be the member of windows network to have access to the application.

4. Difference between src and Code-Behind

Answer: With the 'src' attribute, the source code files are deployed and are compiled by the JIT as needed. Though the code is available to everyone with an access to the server (NOT anyone on the web), this method is preferred as it does away with the compilation of the DLLs. 'CodeBehind' attribute just has the VS.NET associate the code file with the aspx file. This is necessary since VS.NET automates the pre-compiling that is harder by hand. Due to this the 'Src' attribute is done away with having only a DLL to be deployed enhancing the protection level even though it can be decompiled. Src: is a way mention the name of the code-behind class to dynamically compile on the request for a page. Code-behind: is the logic written behind the UI design file. It specifies the name of the compiled file that contains the class. Code-behind attribute is only used for.Net.

5. Explain different IIS isolation levels in ASP.NET- Low (IIS process A), Medium (Pooled), High (Isolated)

Answer: Low (IIS Process): This is the fastest and the default IIS4 setting. ASP pages run in INetInfo.exe and so they are executed in-process. If ASP crashes, IIS too does and must be restarted. Medium (Pooled): This IIS setting is more reliable. In this if ASP crashes, IIS does not. In this, the ASP applications share the same process, so a web site can run with just IIS and ASP process. IIS5 supports this setting and is the default setting. High (Isolated): This setting runs in MTS.EXE in IIS4 and in DLLHOST.EXE in IIS5. If one ASP application crashes, IIS or other ASP applications don't crash. Each ASP application runs out-process in its own space.

6. Define Session, SessionId and Session State in ASP.NET.

Answer: A session is the duration of connectivity between a client and a server application. SessionId is used to identify request from the browser. By default, value of SessionIdis stored in a cookie. You can configure the application to store SessionId in the URL for a "cookieless" session.

7. How would you create a permanent cookie?

Answer: - Permanent cookies are stored on the hard disk and are available until a specified expiration date is reached. - To create a cookie that never expires set its Expires property equal to DateTime.maxValue.

8. What is application domain?

Answer: It is the process space within which ASP.NET application runs. Every application has its own process space which isolates it from other application. If one of the application domains throws error it does not affect the other application domains.

9. Explain ASP.NET Web Forms.

Answer: - Web Forms are an extremely important part of ASP.NET. - They are the User Interface (UI) elements which provide the desired look and feel to your web applications. - Web Forms provide properties, methods, and events for the controls that are placed onto them.

10. Write namespace for user locale in ASP.NET

Answer: System.Web.UI.Page.Culture

11. Describe state management in ASP.NET.

Answer: State management is a technique to manage a state of an object on different request. The HTTP protocol is the fundamental protocol of the World Wide Web. HTTP is a stateless protocol means every request is from new user with respect to web server. HTTP protocol does not provide you with any method of determining whether any two requests are made by the same person. Maintaining state is important in any web application. There are two types of state management system in ASP.NET. - Client-side state management - Server-side state management

12. Define cookie.

Answer: A cookie is a small file on the client computer that a web application uses to maintain current session information. Cookies are used to identity a user in a future session.

13. What are the various types of Cookies in ASP.NET?

Answer: There exist two types of cookies in ASP.NET - Session Cookie - It resides on the machine of the client for a single session and works until the user logs out of the session. - Persistent Cookie - It resides on the machine of a user for a specified period. This period can be set up manually by the user.

14. File-based dependency and key-based dependency.

Answer: - In file-based dependency, the dependency is on a file saved in a disk while in key-based dependency, you depend on another cached item.

15. Explain how a web application works.

Answer: A web application resides in the server and serves the client's requests over internet. The client access the web page using browser from his machine. When a client makes a request, it receives the result in the form of HTML which are interpreted and displayed by the browser. A web application on the server side runs under the management of Microsoft Internet Information Services (IIS). IIS passes the request received from client to the application. The application returns the requested result in the form of HTML to IIS, which in turn, sends the result to the client.

16. Explain the concepts of resource manager class.

Answer: ResourceManager class: It provides convenient access to resources that are culture-correct. The access is provided at run time. This class provides resource withdrawal when a localized resource does not exist. It helps in resource serialization, and provides access to resources that are not packaged in your assembly. It is very much possible to derive classes from ResourceManager class and create our own custom resource solutions.

17. What are the benefits and limitations of using hidden fields?

Answer: Advantages: a. Easy to implement b. Hidden fields are supported by all browsers c. Enables faster access of information because data is stored on client side Disadvantages: a. Not secure because the data is stored on Client side. b. Decreases page performance if too many hidden fields c. Only support single value.

18. Explain Culture and UICulture values.

Answer: - Culture value determines the functions like Date and Currency used to format data and numbers in a Web page. - UICulture value determines the resources like strings or images loaded in a Web application for a Web page.

19. What are HTTP handlers in ASP.NET?

Answer: HTTP handlers, as the name suggests, are used to handle user requests for Web application resources. They are the backbone of the request-response model of Web applications. There is a specific event handler to handle the request for each user request type and send back the corresponding response object. Each user requests to the IIS Web server flows through the HTTP pipeline, which refers to a series of components (HTTP modules and HTTP handlers) to process the request. HTTP modules act as filters to process the request as it passes through the HTTP pipeline. The request, after passing through the HTTP modules, is assigned to an HTTP handler that determines the response of the server to the user request. The response then passes through the HTTP modules once again and is then sent back to the user. You can define HTTP handlers in the <httpHandlers> element of a configuration file. The <add> element tag is used to add new handlers and the <remove> element tag is used to remove existing handlers. To create an HTTP handler, you need to define a class that implements the IHttpHandler interface.

20. Define ViewState in ASP.NET

Answer: It allows the state of objects (serializable) to be stored in a hidden field on the page. It is transported to the client and back to the server, and is not stored on the server or any other external source. It is usedto retain the state of server-side objects between postbacks.

21. What are script injection attacks?

Answer: Script injection attacks called Cross-site scripting (XSS) attacks exploit vulnerabilities in Web page validation by injecting client-side script code. This code executes on the user's browser after the browser downloads the script code from a trusted site and then the browser has no way of determining the legitimacy code. Script injection attacks occur when an end user tries to fill in malicious code in the form or input fields of a form to access database or change it or destroy it. The malicious code tries to fool the application, that it was just another end user. The technique involves submitting contents wrapped in <script>, <object>, <applet>, <embed>, <frame>, <link> etc tags. Request validation and validating the input provided by the end user are a solution to such attacks. One can use the following in the web.config for validating requests for all pages in the application. <configuration> <appSettings/> <connectionStrings/> <system.web> <pages validateRequest="false"/> </system.web> </configuration>

22. Explain cookies with example.

Answer: A cookie is a small amount of data that server creates on the client. When a web server creates a cookie, an additional HTTP header is sent to the browser when a page is served to the browser. The HTTP header looks like this: Set-Cookie: message=Hello. After a cookie has been created on a browser, whenever the browser requests a page from the same application in the future, the browser sends a header that looks like this: Cookie: message=Hello Cookie is little bit of text information. You can store only string values when using a cookie. There are two types of cookies: - Session cookies - Persistent cookies. A session cookie exists only in memory. If a user closes the web browser, the session cookie delete permanently. A persistent cookie, on the other hand, can available for months or even years. When you create a persistent cookie, the cookie is stored permanently by the user's browser on the user's computer. Creating cookie protected void btnAdd_Click(object sender, EventArgs e) { Response.Cookies[''message''].Value = txtMsgCookie.Text; } // Here txtMsgCookie is the ID of TextBox.// cookie names are case sensitive. Cookie named message is different from setting a cookie named Message. The above example creates a session cookie. The cookie disappears when you close your web browser. If you want to create a persistent cookie, then you need to specify an expiration date for the cookie. Response.Cookies[''message''].Expires = DateTime.Now.AddYears(1); Reading Cookiesvoid Page_Load() { if (Request.Cookies[''message''] != null) lblCookieValue.Text = Request.Cookies[''message''].Value; } // Here lblCookieValue is the ID of Label Control.

23. Explain the important principle of SOA.

Answer: A service-oriented architecture is collection of services which communicate with one another other. The communication can range from simple data passing to two or more services organizing some activity.

24. What is the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control?

Answer: You can select more than one HtmlInputCheckBox control from a group of HtmlInputCheckBox controls; whereas, you can select only a single HtmllnputRadioButton control from a group ofHtmlInputRadioButton controls.

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

Answer: Items stored in the ViewState exist for the life of the current page. This includes postbacks (to the same page).

26. What is the difference between adding items into cache through the Add() method and through theInsert() method?

Answer: Both methods work in a similar way except that the Cache.Add() function returns an object that represents the item you added in the cache. The Cache.Insert() function can replace an existing item in the cache, which is not possible using the Cache.Add() method.

27. What is the use of Web.config file?

Answer: Following are the setting you can incorporate in web.config file. Database connections Error Page setting Session States Error Handling Security Trace setting Culture specific setting

28. Why is exception handlingimportantfor an application?

Answer: Exception handling is used to prevent application from being stuck due to unusual occurrences. If the exceptions are handled properly, the application will never get terminated abruptly.

29. Explain the steps to be followed to use Passport authentication.

Answer: 1. Install the Passport SDK. 2. Set the application's authentication mode to Passport in Web.config. 3. Set authorization to deny unauthenticated users. 3. Use the PassportAuthentication_OnAuthenticate event to access the user's Passport profile to identify and authorize the user. 4. Implement a sign-out procedure to remove Passport cookies from the user's machine.

30. What is the difference between URL and URI?

Answer: A URL (Uniform Resource Locator) is the address of some resource on the Web. A resource is nothing but a page of a site. There are other type of resources than Web pages, but that's the easiest conceptually. A URI is a unique identifier to usually a namespace. Though it looks like a URL but it doesn't have to necessarily locate any resource on the web. URI is a generic term. URL is a type of URI. URI- Uniform Resource Identifier: it's a string and its responsibility is to identify a resource by meta-information. It gives information about only one resource. URL- Uniform Resource Locator: identifies the resource on the net and tells it is obtainable using what protocols.

31. Namespace and Assembly.

Answer: - Namespace is a naming convenience for logical design-time while an assembly establishes the name scope for types at run time.

32. What is Shared (static) member?

Answer: Itbelongs to the type but not to any instance of a type. Itcan be accessed without creating an instance of the type. It can beaccessed using the type name instead of the instance name. Itcan't refer to any instance data.

33. Explain ViewState.

Answer: - It is a .Net mechanism to store the posted data among post backs. - It allows the state of objects to be stored in a hidden field on the page, saved on client side and transported back to server whenever required.

34. Describe the sequence of action takes place on the server when ASP.NET application starts first time

Answer: Following are the sequences: IIS starts ASP.NET worker process - worker process loads assembly in the memory - IIS sends the request to the assembly - the assembly composes a response using program logic - IIS returns the response to the user in the form of HTML.

35. What is the basic difference between ASP and ASP.NET?

Answer: The basic difference between ASP and ASP.NET is that ASP is interpreted; whereas, 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).

36. Describe Boxing and Unboxing.

Answer: Boxing allows you to treat a value type the same as a reference type. Unboxing converts a boxed reference type back to a value type.

37. Difference between ASP.NET WebForms and ASP.NET MVC?

Answer: ASP.NET Web Forms uses Page controller pattern approach for rendering layout. In this approach, every page has it's own controller i.e. code-behind file that processes the request. On the other hand, ASP.NET MVC uses Front Controller approach. In this approach a common controller for all pages, processes the requests. Please follow for detailed information on WebForms Vs MVC.

38. What is the difference between a HyperLink control and a LinkButton control?

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

39. What is Authorization in ASP.NET?

Answer: Usually after a user is authenticated by means of a login, the process of authorization is followed where the decision is made whether a user should be granted access to a specific resource. There are 2 ways to authorize access to a given resource: URL authorization: URL authorization is performed by the UrlAuthorizationModule It maps users and roles to URLs in ASP.NET applications. File authorization: File authorization is performed by the FileAuthorizationModule. It checks the access control list of the .aspx or .asmx handler file to determine whether a user should have access to the file.

40. Explain how to implement Fragment Cache

Answer: Fragment cache is to store user controls individually within a web form in cache instead of the whole webform as such. The idea is to simply have different cache parameters for different user controls. control1:<%@ OutputCache Duration="40" VaryByParam="none"%> control2:<%@ OutputCache Duration="60" VaryByParam="none"%> If control1 and control2 exist on a single webform together, the values of control1 and control2 would be cached for different durations based on @OutputCache directive.

41. What are the methods fired during the page load? Explain each of them

Answer: Init() - when the page is instantiated. Load() - when the page is loaded into server memory. PreRender() - the brief moment before the page is displayed to the user as HTML Unload() - when page finishes loading.

42. Can you explain the importance of Finalize method in .NET?

Answer: Clean up activities are entrusted to .NET Garbage collector in .NET. But unmanaged resources such as File, COM object etc. are beyond the scope of Garbage collector. For these type of objects, we have Finalize method where clean up code for unmanaged resources can be put.

43. Describe exception handling in ASP.NET.

Answer: Exception handling correct unusual occurrences and prevent application from getting terminated. You can use Try(try) block and Error event procedures to handle exceptions.

44. What is the difference between authentication and authorization?

Answer: Authentication verifies the identity of a user and authorization is a process where you can check whether or not the identity has access rights to the system. In other words, you can say that 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.

45. Passport authentication

Answer: Passport authentication provides authentication using Microsoft's passport service. If passport authentication is configured and users login using passport then the authentication duties are off-loaded to the passport servers. Passport uses an encrypted cookie mechanism to indicate authenticated users. The passport users are considered authenticated while the rest are redirected to the passport servers to log in, after which they are redirected back to the site. Passport Software Development Kit can be downloaded and installed http:// msdn.microsoft.com/library/default.asp?url=/downloads/list/websrvpass.aps.

46. What are the validation controls available in ASP.NET?

Answer: ASP.NET validation controls are: RequiredFieldValidator: This validates controls if controls contain data. CompareValidator: This allows checking if data of one control match with other control. RangeValidator: This verifies if entered data is between two values. RegularExpressionValidator: This checks if entered data matches a specific format. CustomValidator: Validate the data entered using a client-side script or a server-side code. ValidationSummary: This allows developer to display errors in one place.

47. What is AutoPostback?

Answer: AutoPostBack automatically posts the page back to the server when state of the control is changed.

48. How do you create Master Page?

Answer: Steps to create Master Page Right-click your web project in the Solution Explorer window Select Add New Item. Select the Master Page item type from the Add New Item dialog. Following is an example of Master Page and a Content Page. <%@ Master %> <html> <body> <Title>Title of the Pages</Title> <asp:ContentPlaceHolder id="Content1" runat="server"> </asp:ContentPlaceHolder> </body> </html> This is simple HTML page that serves template for other pages. The @ Master directive at the top of the page defines that the page is Master Page. A placeholder tag <asp:ContentPlaceHolder> is overridden by the content page to place the content. You can have many placeholders tag each of them with different id. Content Page Example %@ Page MasterPageFile="master1.master" %> <asp:Content ContentPlaceHolderId="Content1" runat="server"> <h1>ASP Interview Questions</h1> </asp:Content> When you request this page, ASP.NET merges layout specified in the Master Page and content of content page to produce page result.

49. What does WSDL stand for? Explain its purpose

Answer: Web Services Description Language.

50. Explain the types of Workflow in Windows Workflow Foundation.

Answer: There are 3 types of workflows in WWF: Sequential Workflow:The sequential workflow style executes a set of contained activities in order, one by one and does not provide an option to go back to any step. State Machine Workflow:It represents the workflow in the form of a state machine containing set of states, each of them receiving events. These events lead to transition from one state to another one. Rules-driven Workflow:It is based on Sequential/StateMachine workflow.

51. What are the types of Authentication in ASP.NET?

Answer: There are three types of authentication available in ASP.NET: • Windows Authentication: This authentication method uses built-in windows security features to authenticate user. • Forms Authentication: authenticate against a customized list of users or users in a database. • Passport Authentication: validates against Microsoft Passport service which is basically a centralized authentication service.

52. Describe in brief .NET Framework and its components.

Answer: .NET Framework provides platform for developing windows and web software. ASP.NET is a part of .Net framework and can access all features implemented within it that was formerly available only through windows API. .NET Framework sits in between our application programs and operating system. The .Net Framework has two main components: .Net Framework Class Library: It provides common types such as data types and object types that can be shared by all .Net compliant language. The Common language Runtime: It provides services like type safety, security, code execution, thread management, interoperability services.

53. Briefly explain how to specify remoting parameters using config files.

Answer: The remoting parameters can be specified through both programming and in config files. All the settings defined in config files are placed under <system.runtime.remoting> <application> is placed under system.runtime.remoting but the name attribute of application tag specifies if the parameter is for server or client. RemotingConfiguration.Configure is used to access the configuration keys for remoting properties.

54. How to turn off cookies for a page?

Answer: Cookie.Discard Property when true, instructs the client application not to save the Cookie on the user's hard disk when a session ends.

55. Describe how Passport authentication works.

Answer: ASP.NET application with Passport authentication implemented checks the user's machine for a current passport authentication cookie. If it is not available, ASP.NET directs the user to a Passport sign-on page. The Passport service authenticates the user, stores an authentication cookie on the user's computer and direct the user to the requested page.

56. What are the various session state management options provided by ASP.NET?

Answer: - ASP.NET provides two session state management options - In-Process and Out-of-Process state management. - In-Process stores the session in memory on the web server. - Out-of-Process stores data in an external data source. This data source may be a SQL Server or a State Server service. Out-of-Process state management needs all objects stored in session to be serializable.

57. Explain the types of Caching using Cache object of ASP.NET.

Answer: • Page output:Is used to fetch information or data at page level. It is best used when the site is mainly static. Used by declaring the output page directive • Page fragment:Is used to cache the structure level information. It is used when parts of pages change. For example: user control • Programmatic or data:Is used to fetch the information of an application quickly based on the requirements.

58. Explain how to pass a querystring from an .asp page to aspx page.

Answer: Consider the following URL: http:// localhost/form.aspx?param1=career&param2=ride This html addresses use QueryString property to pass values between pages. From the URL above the information obtained is: form.aspx: which is the destination page for your browser. Param1 is the first parameter, the value of which is set to career Param2 is the first parameter, the value of which is set to ride The '?' marks the beginning of the QueryString '&' is used as a separator between parameters. private void formButtonSubmit_Click(object sender, System.EventArgs e) { Response.Redirect("form.aspx?Param1=" + this.formTextfieldParam1.Text + "&Param2=" + this. formTextfieldParam2.Text); } The above code is a submit button event handler and it sends the values of the query string to the second page. The following code demonstrates how to retrieve these valus on the second page: private void Page_Load(object sender, System.EventArgs e) { this.form2TextField1.Text = Request.QueryString["Param1"]; this. form2TextField2.Text = Request.QueryString["Param2"]; } You can also use the following method to retrieve the parameters in the string: for (int i =0;i < Request.QueryString.Count;i++) { Response.Write(Request.QueryString[i]); } From HTML in asp page:<ahref="abc.aspx?qstring1=test">Test Query String</a> From server side code: <%response.redirect "webform1.aspx?id=11"%>

59. What is Windows communication foundation, WCF?

Answer: WCF is a framework that builds applications that can inter-communicate based on service oriented architecture consuming secure and reliable web services. This also helps in Distributed computing. The WCF also brings together the various communication models into a single model.

60. How many types of validation controls are provided by ASP.NET? Explain them.

Answer: 5 Types of validation control exists: • RequiredFieldValidator:To enforce a user to fill a particular field before submitting the form. This is done when the field is a mandatory input .e.g.: username & password • RangeValidator:To validate if the user input fits within a range of lower and upper limits. • CompareValidator:This is to compare the user input against other existing value. • RegularExpressionValidator:This is to ensure that the use input is as per the expected pattern. e.g.: Phone number, emails • CustomValidator:Custom validator allows developers to create their own validators based on their logics. This could be a mix of other validators.

61. What are the various types of validation controls provided by ASP.NET?

Answer: ASP.NET provides 6 types of validation controls as listed below: i.) RequiredFieldValidator - It is used when you do not want the container to be empty. It checks if the control has any value or not. ii.) RangeValidator - It checks if the value in validated control is within the specified range or not. iii.) CompareValidator - Checks if the value in controls matches some specific values or not. iv.) RegularExpressionValidator - Checks if the value matches a specific regular expression or not. v.) CustomValidator - Used to define User Defined validation. vi.) Validation Summary -Displays summary of all current validation errors on an ASP.NET page.

62. What is ASP.NET?

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

63. What is ObjRef object in remoting?

Answer: ObjRef is a searializable object returned by Marshal() that knows about location of the remote object, host name, port number, and object name.

64. Define access modifiers.

Answer: Access modifiers are used to control the scope of type members. There arefive access modifiersthatprovide varying levels of access. Public(public),Friend(internal),Private(private),Protected(protected), andProtected Friend(protected internal)

65. Point to be noted about Application and Session state variables

Answer: These variable can store any type of data. Maintaining Session state affects performance. Session state can be turned off at the application and page levels. Application state variables are available throughout the current process, but not across processes.

66. How you can access the Properties and Controls of Master Pages from content pages?

Answer: You can access the Properties and Controls of Master Pages from content pages. In many situations you need User's Name in different content pages. You can set this value inside the master page and then make it available to content pages as a property of the master page. We will follow the following steps to reference the properties of master page from content pages. Step: 1 Create a property in the master page code-behind file. public String UserName { get { return (String)Session["Name"]; } set { Session ["Name"] = value; } } Step: 2 Add the @ MasterTypedeclaration to the .aspx content page to reference master properties in a content page. This declaration is added just below the @ Page declaration as follows: <%@ Page Title=" TEST" Language="C#" MasterPageFile="~/CareerRide.master" AutoEventWireup="true" CodeFile="CareerRideWelcome.aspx.cs" Inherits="CareerRideWelcome" %> <%@ MasterTypeVirtualPath="~/CareerRide.master" %> Step: 3 Once you add the @ MasterType declaration, you can reference properties in the master page using the Master class. For example take a label control that id is ID="Label1" Label1.Text= Master.UserName ; For referencing controls in the Master Page we will write the following code. Content Page Code. protected void Button1_Click(object sender, EventArgs e) { TextBox txtName= (TextBox)Master.FindControl("TextBox1"); Label1.Text=txtName.Text; } To reference controls in a master page, callMaster.FindControlfrom the content page.

67. List out the difference between windows authentication and form authentication.

Answer: Windows authentication uses windows account whereas form authentication maintains its own user list. Windows authentication is best suited for the application which is meant for a corporate users whereas form authentication is preferable for the applications which have diversified users fromseveral places. User lists for windows authentication are found in <authorization>element whereas in case of form authentication, lists are there in <credential> element of web.config file.

68. What are the events in GLOBAL.ASAX file?

Answer: Global.asax file contains the following events: Application_Init Fired when an application initializes or is first called. It is invoked for all HttpApplication object instances. Application_Disposed Fired just before an application is destroyed. This is the ideal location for cleaning up previously used resources. Application_Error Fired when an unhandled exception is encountered within the application. Application_Start Fired when the first instance of the HttpApplication class is created.It allows you to create objects that are accessible by all HttpApplication instances. Application_End Fired when the last instance of an HttpApplication class is destroyed. It is fired only once during an application's lifetime. Application_BeginRequest Fired when an application request is received. It is the first event fired for a request, which is often a page request (URL) that a user enters Application_EndRequest The last event fired for an application request. Application_PreRequestHandlerExecute Fired before the ASP.NET page framework begins executing an event handler like a page or Web service. Application_PostRequestHandlerExecute Fired when the ASP.NET page framework has finished executing an event handler Applcation_PreSendRequestHeaders Fired before the ASP.NET page framework sends HTTP headers to a requesting client (browser) Application_PreSendContent Fired before the ASP.NET page framework send content to a requesting client (browser). Application_AcquireRequestState Fired when the ASP.NET page framework gets the current state (Session state) related to the current request. Application_ReleaseRequestState Fired when the ASP.NET page framework completes execution of all event handlers. This results in all state modules to save their current state data Application_ResolveRequestCache Fired when the ASP.NET page framework completes an authorization request. It allows caching modules to serve the request from the cache, thus bypassing handler execution. Application_UpdateRequestCache Fired when the ASP.NET page framework completes handler execution to allow caching modules to store responses to be used to handle subsequent requests Application_AuthenticateRequest Fired when the security module has established the current user's identity as valid. At this point, the user's credentials have been validated Application_AuthorizeRequest Fired when the security module has verified that a user can access resources Session_Start Fired when a new user visits the application Web site Session_End Fired when a user's session times out, ends, or they leave the application Web site

69. What is the use of ComVisible attribute?

Answer: ComVisible attribute is used to select which public .NET classes and members are visible to COM.

70. What tag do you use to add a hyperlink column to the DataGrid?

Answer: <asp:HyperLinkColumn>

71. Whatare the Application_Start and Session_Start subroutines used for?

Answer: These subroutines set the variables for the Application and Session objects.

72. What is caching?

Answer: Caching is the technique of storing frequently used items in memory so that they can be accessed more quickly. By caching the response, the request is served from the response already stored in memory. It's important to choose the items to cache wisely as Caching incurs overhead. A Web form that is frequently used and does not contain data that frequently changes is good for caching. A cached web form freezes form's server-side content and changes to that content do not appear until the cache is refreshed.

73. What are the options in ASP.NET to maintain state?

Answer: Client-side state management This maintains information on the client's machine using Cookies, View State, and Query Strings. Cookies A cookie is a small text file on the client machine either in the client's file system or memory of client browser session. Cookies are not good for sensitive data. Moreover, Cookies can be disabled on the browser. Thus, you can't rely on cookies for state management. View State Each page and each control on the page has View State property. This property allows automatic retention of page and controls state between each trip to server. This means control value is maintained between page postbacks. Viewstate is implemented using _VIEWSTATE, a hidden form field which gets created automatically on each page. You can't transmit data to other page using view state. Querystring Query strings can maintain limited state information. Data can be passed from one page to another with the URL but you can send limited size of data with the URL. Most browsers allow a limit of 255 characters on URL length. Server-side state management This kind of mechanism retains state in the server. Application State The data stored in the application object can be shared by all the sessions of the application. Application object stores data in the key value pair. Session State Session State stores session-specific information and the information is visible within the session only. ASP.NET creates unique sessionId for each session of the application. SessionIDs are maintained either by an HTTP cookie or a modified URL, as set in the application's configuration settings. By default, SessionID values are stored in a cookie. Database Database can be used to store large state information. Database support is used in combination with cookies or session state.

74. Define Windows and Forms authentication.

Answer: Windows authentication is the default authentication method of the ASP.NET application. It uses security scheme of windows operating system of corporate network. Windows authentication uses user names, passwords, and permissions of network resources and Web applications. User lists for Windows authentication are included in theelement of Web.config. Form authentication allows creating own database of users in the application's Web.config file or in a separate user database and validate the identity of the users when they visit Web site. Users do not have to be member of a domain-based network to have access to your application.

75. Client-side and server-side validations in Web pages.

Answer: - Client-side validations happends at the client's side with the help of JavaScript and VBScript. This happens before the Web page is sent to the server. - Server-side validations occurs place at the server side.

76. Explain the purpose of EnableViewState property

Answer: It allows the page to save the users input on a form across postbacks. It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page beforesending the page to the clients browser. When the page is posted back to the server, the server control is recreatedwith the state stored in viewstate.

77. What is Language Integrated Query (LINQ)?

Answer: LINQ is a set of extensions to .NET Framework that encapsulate language integrated query, set and other transformation operations. It extends VB, C# with their language syntax for queries. It also provides class libraries which allow a developer to take advantages of these features.

78. Define namespace.

Answer: Namespaces are the way to organize programming code. It removes the chances of name conflict. It is quite possible to have one name for an item accidentally in large projects those results into conflict. By organizing your code into namespaces, you reduce the chance of these conflicts. You can create namespaces by enclosing a class in a Namespace...End Namespace block. You can use namespaces outside your project by referring them using References dialog box. You can use Imports or using statement to the code file to access members of the namespaces in code.

79. What is an ASP.NET Web Form?

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

80. How do Cookies work? Give an example of their abuse.

Answer: - The server directs the browser to put some files in a cookie. All the cookies are then sent for the domain in each request. - An example of cookie abuse could be a case where a large cookie is stored affecting the network traffic.

81. Globalization and localization.

Answer: - Globalization is a technique to identify the part of a Web application that is different for different languages and separate it out from the web application while in localization you try to configure a Web application so that it can be supported for a specific language or locale.

82. Explain the concepts of CODE Page approach. What are the disadvantages of this approach?

Answer: Code Page was used before Unicode came into existence. It was a technique to represent characters in different languages. It was a different interpretation of ASCII set which means it kept 128 characters for English and rest 128 were specifically tailored for other languages. Disadvantages: a. Languages like Japanese and Chinese having more than 5000 characters were difficult to represent n 128 character set. b. Clients also need to have a support for code page. c. It's representation is done on the basis of operating system.

83. Describe Web application's life cycle.

Answer: A Web application starts with the first request for a resource. On request, Web forms are instantiated and processed in the server. Server sends its response to the client. Application ends once all client sessions end.

84. Define Tracing.

Answer: Tracing is the way to maintain events in an application. It is useful while the application is in debugging or in the testing phase. The trace class in the code is used to diagnose problem. You can use trace messages to your project to monitor events in the released version of the application. The trace class is found in the System.Diagnostics namespace. ASP.NET introduces tracing that enables you to write debug statements in

Show more