

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
ASP.NET AND WEB INTERVIEW QUESTIONS
Typology: Exams
1 / 25
This page cannot be seen from the preview
Don't miss anything!


















Advantages of ASP.NET? Separation of Code from HTML: To make a clean sweep, with ASP.NET you have the ability to completely separate layout and business logic. This makes it much easier for teams of programmers and designers to collaborate efficiently. Support for compiled languages: Developer can use VB.NET and access features such as strong typing and object-oriented programming. Using compiled languages also means that ASP.NET pages do not suffer the performance penalties associated with interpreted code. ASP.NET pages are precompiled to byte-code and Just In Time (JIT) compiled when first requested. Subsequent requests are directed to the fully compiled code, which is cached until the source changes. Use services provided by the .NET Framework: The .NET Framework provides class libraries that can be used by your application. Some of the key classes help you with input/output, access to operating system services, data access, or even debugging. We will go into more detail on some of them in this module. Graphical Development Environment: Visual Studio .NET provides a very rich development environment for web developers. You can drag and drop controls and set properties the way you do in Visual Basic 6. And you have full IntelliSense support, not only for your code, but also for HTML and XML. State management: To refer to the problems mentioned before, ASP.NET provides solutions for session and application state management. State information can, for example, be kept in memory or stored in a database. It can be shared across web farms, and state information can be recovered, even if the server fails or the connection breaks down. Update files while the server is running: Components of your application can be updated while the server is online and clients are connected. The framework will use the new files as soon as they are copied to the application. Removed or old files that are still in use are kept in memory until the clients have finished. XML-Based Configuration Files:
Configuration settings in ASP.NET are stored in XML files that you can easily read and edit. You can also easily copy these to another server, along with the other files that comprise your application. What is ASP.NET? ASP.NET provides services to allow the creation, deployment, and execution of Web Applications and Web Services. Like ASP, ASP.NET is a server-side technology What are the different validators in ASP.NET? ASP.NET validation controls define an important role in validating the user input data. Whenever the user gives the input, it must always be validated before sending it across to various layers of an application. If we get the user input with validation, then chances are that we are sending the wrong data. So, validation is a good idea to do whenever we are taking input from the user. There are the following two types of validation in ASP.NET: Client-Side Validation Server-Side Validation Client-Side Validation? When validation is done on the client browser, then it is known as Client-Side Validation. We use JavaScript to do the Client-Side Validation. Server-Side Validation: When validation occurs on the server, then it is known as Server-Side Validation. Server-Side Validation is a secure form of validation. The main advantage of Server-Side Validation is if the user somehow bypasses the Client-Side Validation, we can still catch the problem on server-side. The following are the Validation Controls in ASP.NET: RequiredFieldValidator Control CompareValidator Control RangeValidator Control RegularExpressionValidator Control CustomFieldValidator Control ValidationSummary What is View State? View State is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.
Server-side state management enables you to manage application-related and session-related information on the server. ASP.NET provides the following options to manage state at the server side: Application state Session state What is caching in ASP.NET? Caching is one of the most interesting concept and operation in ASP.NET. If you can handle it, you can run any web application by applying the caching concept depending on the requirements. Caching is for providing solutions or the results to the users depending on their request, admin needs to recreate the pages often depending on user requests...STOP!!! "A cache simply stores the output generated by a page in the memory and this saved output (cache) will serve us (users) in the future.". Types caching: page caching Fragment caching Data caching How can we apply themes in ASP.NET application? A theme is a collection of settings that define the look of controls and web pages. These themes are applied across all the pages in a web application to maintain a consistent appearance. Themes are included images and skin files; the skin files set the visual properties of ASP.NET controls. Themes are of two types: Page Theme A Page theme contains the control skins, style sheets, graphic files, and other resources inside the subfolder of the App_Theme folder in the Solution Explorer window. A page theme is applied to a single page of the web site. Global Theme A Global theme is a theme that is applied to all the web sites on a web server and includes property settings, and graphics. This theme allows us to maintain all the websites on the same web server and define the same style for all the web pages of the web sites. What is MVC?
Model-View-Controller (MVC) is a pattern to separate an application into the following three main components: Model View Controller The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating web applications. The ASP.NET MVC Framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentications. The MVC framework is defined in the System.Web.Mvc assembly. It provides full control over HTML, JavaScript and CSS. It's the better as well as a recommended approach for large-scale applications where various teams are working together. What are the ASP.NET MVC framework advantages: It makes it very easy to manage complexity by dividing an application into the Model, View and Controller. It does not use view state or server-based forms. Full control over HTML, JavaScript and CSS. It provides better support for Test-Driven Development (TDD). It works well for Web applications that are supported by large teams of developers and for web designers who need a high degree of control over the application behaviour. By default support of Facebook and Google Authentication. It easy to manage a large application to divide in multiple area What are Cookies in ASP.NET? Cookies are a State Management Technique that can store the values of control after a post-back. Cookies can store user-specific Information on the client's machine like when the user last visited your site. Cookies are also known by many names, such as HTTP Cookies, Browser Cookies, Web Cookies, Session Cookies and so on. Basically cookies are a small text file sent by the web server and saved by the Web Browser on the client's machine. List of properties containing the HttpCookies Class: Domain: Using these properties we can set the domain of the cookie. Expires: This property sets the Expiration time of the cookies. HasKeys: If the cookies have a subkey then it returns True. Name: Contains the name of the Key. Path: Contains the Virtual Path to be submitted with the Cookies. Secured: If the cookies are to be passed in a secure connection then it only returns True. Value: Contains the value of the cookies. Limitation of the Cookies The size of cookies is limited to 4096 bytes. A total of 20 cookies can be used in a single website.
Programmable (encapsulates a task). Based on XML (open, text-based standard). Self-describing (metadata for access and use). Discoverable (search and locate in registries)- ability of applications and developers to search for and locate desired Web services through registries. This is based on UDDI. Key Web Service Technologies:? XML- Describes only data. So, any application that understands XML-regardless of the application's programming language or platform-has the ability to format XML in a variety of ways (well-formed or valid). SOAP- Provides a communication mechanism between services and applications. WSDL- Offers a uniform method of describing web services to other programs. UDDI- Enables the creation of searchable Web services registries. What are the Advantages of ASP.NET? Separation of Code from HTML Support for compiled languages Use services provided by the .NET Framework Graphical Development Environment Update files while the server is running XML-Based Configuration Files What is the concepts of Globalization and Localization in .NET? Localization means "process of translating resources for a specific culture", and Globalization means "process of designing applications that can adapt to different cultures". Proper Globalization: Your application should be able to Accept, Verify, and Display all global kind of data. It should well also be able to operate over this data, accordingly. We will discuss more about this "Accordingly operations over diff. culture data". Localizability and Localization: Localizability stands for clearly separating the components of culture based operations regarding the user interface, and other operations from the executable code. What is the Web.config file in ASP? Configuration file is used to manage various settings that define a website. The settings are stored in XML files that are separate from your application code. In this way you can configure settings independently from your code. Generally a website contains a single Web.config file stored inside the
application root directory. However there can be many configuration files that manage settings at various levels within an application. Usage of configuration file? ASP.NET Configuration system is used to describe the properties and behaviors of various aspects of ASP.NET applications. Configuration files help you to manage the settings related to your website. Each file is an XML file (with the extension .config) that contains a set of configuration elements. Configuration information is stored in XML-based text files. Benefits of XML-based Configuration files: ASP.NET Configuration system is extensible and application specific information can be stored and retrieved easily. It is human readable. You need not restart the web server when the settings are changed in configuration file. ASP.NET automatically detects the changes and applies them to the running ASP.NET application. You can use any standard text editor or XML parser to create and edit ASP.NET configuration files. What is the App Domain Concept in ASP.NET? ASP.NET introduces the concept of an Application Domain which is shortly known as AppDomain. It can be considered as a Lightweight process which is both a container and boundary. The .NET runtime uses an AppDomain as a container for code and data, just like the operating system uses a process as a container for code and data. As the operating system uses a process to isolate misbehaving code, the .NET runtime uses an AppDomain to isolate code inside a secure boundary. The CLR can allow the multiple .NET applications to run in a single AppDomain. Mulitple Appdomains can exist in Win32 process. What is Query String in ASP? A QueryString is a collection of characters input to a computer or web browser. A Query String is helpful when we want to transfer a value from one page to another. When we need to pass content between the HTML pages or aspx Web Forms in the context of ASP.NET, a Query String is Easy to use and the Query String follows a separating character, usually a Question Mark (?). It is basically used for identifying data appearing after this separating symbol. A Query String Collection is used to retrieve the variable values in the HTTP query string. If we want to transfer a large amount of data then we can't use the Request.QueryString. Query Strings are also generated by form submission or can be used by a user typing a query into the address bar of the browsers. What is master page in ASP.NET? The extension of MasterPage is '.master'. MasterPage cannot be directly accessed from the client because it just acts as a template for the other Content Pages. In a MasterPage we can have content either inside ContentPlaceHolder or outside it. Only content inside the ContentPlaceHolder can be customized in the Content Page. We can have multiple masters in one web application.A MasterPage can have another MasterPage as Master to it. The MasterPageFile property of a webform can be set dynamically and it should be done either in or before the Page_PreInit event of the WebForm.
binding with ADO.NET and Web controls to populate control contents from SQL select statements or stored procedures. Data binding uses a special syntax: <%# %> The <%#, which instructs ASP.NET to evaluate the expression. The difference between a data binding tags and a regular code insertion tags <% and %> becomes apparent when the expression is evaluated. Expressions within the data binding tags are evaluated only when the DataBind method in the Page objects or Web control is called. Following are data bind controls in ASP.NET: Repeater Control DataGrid Control DataList Control GridView Control DetailsView FormView DropDownList ListBox RadioButtonList CheckBoxList BulletList etc. What are the major events in global.aspx? The Global.asax file, which is derived from the HttpApplication class, maintains a pool of HttpApplication objects, and assigns them to applications as needed. The Global.asax file contains the following events: Application_Init Application_Disposed Application_Error Application_Start Application_End Application_BeginReques Use of CheckBox in .NET? The CheckBox control is a very common control of HTML, unlike radio buttons it can select multiple items on a webpage. The CheckBox control in ASP.NET has many properties and some of them are listed below. Property Description AutoPostBack Specifies whether the form should be posted immediately after the Checked property has changed or not. The default is false. CausesValidation Specifies if a page is validated when a Button control is clicked.
Checked Specifies whether the check box is checked or not. InputAttributes Attribute names and values used for the Input element for the CheckBox control. LabelAttributes Attribute names and values used for the Label element for the CheckBox control. runat Specifies that the control is a server control. Must be set to "server". Text The text next to the check box. TextAlign On which side of the check box the text should appear (right or left). ValidationGroup Group of controls for which the Checkbox control causes validation when it posts back to the server. OnCheckedChanged The name of the function to be executed when the Checked property has changed. What is the authentication and authorization in ASP.NET? Authentication: Prove genuineness Authorization: process of granting approval or permission on resources. In ASP.NET authentication means to identify the user or in other words its nothing but to validate that he exists in your database and he is the proper user. Authorization means does he have access to a particular resource on the IIS website. A resource can be an ASP.NET web page, media files (MP4, GIF, JPEG etc), compressed file (ZIP, RAR) etc. Types of authentication and authorization in ASP.NET Windows authentication: In this methodology ASP.NET web pages will use local windows users and groups to authenticate and authorize resources. Forms Authentication: This is a cookie based authentication where username and password are stored on client machines as cookie files or they are sent through URL for every request. Form-based authentication presents the user with an HTML-based Web page that prompts the user for credentials. Passport authentication: Passport authentication is based on the passport website provided by the Microsoft .So when user logins with credentials it will be reached to the passport website ( i.e. hotmail,devhood,windows live etc) where authentication will happen. If Authentication is successful it will return a token to your website. Anonymous access: If you do not want any kind of authentication then you will go for Anonymous access. What are the HTML server control in ASP.NET? the Microsoft.NET Framework provides a rich set of server-side controls for developing Web applications. You can add these controls to WebForms pages just as you add Windows controls to a
Whenever the webserver has been restarted or stopped then the information maintained by the application object will be lost. If any data is stored on the application object then that information will be shared upon all the users accessing the webserver. Since the information is shared among all the users, it is advisable to lock and unlock the application object as per requirement. Global Application Class(Global.asax): It is a Class which consists of event handlers which executes the code implicitly whenever a relevant task has been performed on the web server.Design: <%@ Application Language="C#" %>
What is the ASP.NET page life Cycle? When a page is requested by the user from the browser, the request goes through a series of steps and many things happen in the background to produce the output or send the response back to the client. The periods between the request and response of a page is called the "Page Life Cycle". Request: Start of the life cycle (sent by the user). Response: End of the life cycle (sent by the server).
There are four stages that occur during the Page Life Cycle before the HTML Response is returned to the client. Later in this article we"ll study all these stages and their sub events. Initialization Loading Rendering Unloading Describe the 4 steps in page life cycle What is the ASP.NET page life cycle events? Page request When ASP.NET gets a page request, it decides whether to parse and compile the page or there would be a cached version of the page; accordingly the response is sent, Starting of page life cycle At this stage, the Request and Response objects are set. If the request is an old request or post back, the IsPostBack property of the page is set to true. The UICulture property of the page is also set. Page initialization At this stage, the controls on the page are assigned unique ID by setting the UniqueID property and themes are applied. For a new request postback data is loaded and the control properties are restored to the view-state values. Page load At this stage, control properties are set using the view state and control state values. Validation Validate method of the validation control is called and if it runs successfully, the IsValid property of the page is set to true. Postback event handling If the request is a postback (old request), the related event handler is called.
Server.Transfer method for the current request, terminates execution of the current page and starts execution of a new page using the specified URL path of the page. Both Response.Redirect and Server.Transfer has same syntax like: Response.Redirect("UserDetail.aspx"); Server.Transfer("UserDetail.aspx"); Before touching on more points I want to explain some HTTP status codes, these are important for the understanding of the basic differences between these two. The HTTP status codes are the codes that the Web server uses to communicate with the Web browser or user agent. What is page directives in ASP.NET? Basically Page Directives are commands. These commands are used by the compiler when the page is compiled. How to use the directives in an ASP.NET page It is not difficult to add a directive to an ASP.NET page. It is simple to add directives to an ASP.NET page. You can write directives in the following format: <%@[Directive][Attributes]%> See the directive format, it starts with "<%@" and ends with "%>". The best way is to put the directive at the top of your page. But you can put a directive anywhere in a page. One more thing, you can put more than one attribute in a single directive. Here is the full list of directives: @Page @Master @Control @Import @Implements @Register @Assembly @MasterType @Output Cache @PreviousPageType @Reference What is HTTP Handler? Every request into an ASP.NET application is handled by a specialized component known as an HTTP handler. The HTTP handler is the most important ingredient while handling ASP.NET requests. Examples: ASP.NET uses different HTTP handlers to serve different file types. For example, the handler
for web Page creates the page and control objects, runs your code, and renders the final HTML. ASP.NET default handlers: Page Handler (.aspx) - Handles Web pages. User Control Handler (.ascx) - Handles Web user control pages. Web Service Handler (.asmx) - Handles Web service pages. Trace Handler (trace.axd) - Handles trace functionality. Why we need to create our own HTTP Handler: Sometime we need to avoid ASP.NET full page processing model, which saves lot of overheads, as ASP.NET web form model has to go through many steps such as creating web page objects, persisting view state etc. What we are interested into is to develop some low level interface that provides access to objects like Request and Response but doesn't use the full control based web form model discussed above. What are Differences between ASP.NET HttpHandler and HttpModule? The user requests for a resource on web server. The web server examines the file name extension of the requested file, and determines which ISAPI extension should handle the request. Then the request is passed to the appropriate ISAPI extension. For example when an .aspx page is requested it is passed to ASP.NET page handler. Then Application domain is created and after that different ASP.NET objects like Httpcontext, HttpRequest, HttpResponse are created. Then instance of HttpApplication is created and also instance of any configured modules. One can register different events of HttpApplication class like BeginRequest, AuthenticateRequest, AuthorizeRequest, ProcessRequest etc. HTTP Handler HTTP Handler is the process which runs in response to a HTTP request. So whenever user requests a file it is processed by the handler based on the extension. So, custom http handlers are created when you need to special handling based on the file name extension. Let's consider an example to create RSS for a site. So, create a handler that generates RSS-formatted XML. Now bind the .rss extension to the custom handler. HTTP Modules HTTP Modules are plugged into the life cycle of a request. So when a request is processed it is passed through all the modules in the pipeline of the request. So generally http modules are used for: Security: For authenticating a request before the request is handled. Statistics and Logging: Since modules are called for every request they can be used for gathering statistics and for logging information.
controls. The controls on the source page can be accessed via the FindControl method on the object returned by the PreviousPage property of the target page. protected void Page_Load(object sender, EventArgs e) { ... TextBox txtStartDate = (TextBox) PreviousPage.FindControl("txtStartDate "); ... } At this point the target page does not have any knowledge of the source page. The PreviousPage property is of the type Page. For accessing controls using FindControl, the developer has to presume a certain structure in the source web form. This approach using FindControl has a few limitations. FindControl is dependent on the developer to provide the ids of the controls to access. The code will stop working if the control id is changed in the source web form. The FindControl method can retrieve controls only within the current container. If you need to access a control within another control, you need to first get a reference to the parent control. Access source page info within the posted page: @PreviousPageType Directive There is another more direct option to get access to the source page controls if the source page is pre- determined. The @PreviousPageType directive can be used in the target page to strongly type the source page. The directive specifies the source page using either the VirtualPath attribute or the TypeName attribute. The PreviousPage property then returns a strongly typed reference to the source page. It allows access to the public properties of the source page. Explain GridView control in ASP.NET? the GridView control displays the values of a data source in a table. Each column represents a field, while each row represents a record. The GridView control supports the following features: Binding to data source controls, such as SqlDataSource. Built-in sort capabilities. Built-in update and delete capabilities. Built-in paging capabilities. Built-in row selection capabilities. Programmatic access to the GridView object model to dynamically set properties, handle events, and so on. Multiple key fields.
Multiple data fields for the hyperlink columns. Customizable appearance through themes and styles. What is the difference between ASP.NET Web API and WCF? The ASP. NET Web API is a framework that uses the HTTP services and makes it easy to provide the response to the client request. The response depends on the request of the clients. The Web API builds the HTTP services, and handles the request using the HTTP protocols. The request may be GET, POST, DELETE, PUT. We can also say that the ASP. NET Web API: Is an HTTP service. Is designed for reaching the broad range of clients. Uses the HTTP application. We use the ASP. NET Web API for creating the REST ful (Representational State Transfer) services. The following are some important points of the ASP. NET Web API: The ASP. NET Web API supports the MVC application features that are controller, media formatters, routing etcetera. It is a platform for creating the REST services. It is a framework for creating the HTTP services. Responses can be formatted by the APIs MediaTypeFormatter into the Java Script Object Notation (JSON) and Extencible Markup Language (XML) formats. What is the PostBack property in ASP.NET? If we create a web Page, which consists of one or more Web Controls that are configured to use AutoPostBack (Every Web controls will have their own AutoPostBack property), the ASP.NET adds a special JavaScipt function to the rendered HTML Page. This function is named _doPostBack(). When Called, it triggers a PostBack, sending data back to the web Server. Explain Cookie-less Session in ASP.NET. By default a session uses a cookie in the background. To enable a cookie-less session, we need to change some configuration in the Web.Config file. Follow these steps: Open Web.Config file. Add a tag under tag. Add an attribute "cookieless" in the tag and set its value to "AutoDetect" like below:
The possible values for "cookieless" attribute are: AutoDetect: Session uses background cookie if cookies are enabled. If cookies are disabled, then the URL is used to store session information. UseCookie: Session always use background cookie. This is default.