ASP.NET interview question pdf: We have compiled most frequently asked .NET Interview Questions which will help you with different expertise levels.
C#.NET Interview Questions and Answers for Freshers Pdf Free Download
What is ASP.Net?
What are the advantages of ASP.NET?
ASP.Net is the next generation of ASP technology platform. It is superior to ASP in the following ways:
- Highly Scalable
- Compiled Code
- User Authentication
- Language Support
- Third-party control
- Configuration and Deployment are easy,
- Object and Page caching
- Strict coding requirements
What’s the use of Response.Output.Write( )?
We can write formatted output using Response.Output.Write( ).
In which event of page cycle is the ViewState available?
After the lnit( ) and before the Page_Load().
What is the difference between Server. Transfer and Response. Redirect?
In Server. Transfer page processing transfers from one page to the other page without making a round-trip back to the client’s browser. This provides a faster response with a little less overhead on the server. The client url history list or current url Server does not update in the case of the Server. Transfer.
Response. Redirect is used to redirect the user’s browser to another page or site. It performs a trip back to the client where the client’s browser is redirected to the new page. The user’s browser history list is updated to reflect the new address.
From which base class all Web Forms are inherited?
What are the different validators in ASP.NET?
- Required Field Validator
- Range Validator
- Compare Validator
- Custom Validator
- Regular expression Validator
- Summary Validator
Which validator control do you use if you need to make sure the values in two different controls matched?
Compare Validator control.
What is the concept of Postback in ASP.NET?
Postback is a request which is sent from a client to the server from the same page user is working with. There is an HTTP POST request mechanism in ASP.NET. It posts a complete page back to the server to refresh the whole page.
What is the use of “isPostBack” property?
The “IsPostBack” property of the page object is used to check that the page is posted back or not.
How do you identify that the Page is PostBack?
There is a property named “IsPostBack” property in Post object, which can be checked to know that the page is posted back.
What is ViewState?
ViewState is used to retain the state of server-side objects between page post-backs.
Where the ViewState is stored after the page postback?
ViewState is stored in a hidden field on the page on the client-side. ViewState is transported to the client and back to the server and is not stored on the server or any other external source.
How long the items in ViewState exists?
They exist for the life of the current page.
What are the different Session state management options available in ASP.NET?
In-Process stores the session in memory on the web server.
Out-of-Process Session state management stores data in an external server. The external server may be either a SQL Server or a State Server. All objects stored in session are required to be serializable for Out-of-Process state management.
How you can add an event handler?
Using the Attributes property of server side control, e.g.
What is caching?
Caching is a technique used to increase performance by keeping frequently accessed data or files in memory. The request for a cached file/data will be accessed from cache instead of actual location of that file.
what are the main requirements for caching?
- By caching the response, your request is served by the response already stored in memory.
- You must be very careful while choosing the items to cache because Caching incurs overhead.
- A frequently used web form which data doesn’t frequently change 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.
What are the different types of caching?ASP.NET has 3 kinds of caching :
- Output Caching,
- Fragment Caching,
- Data Caching.
Which type if caching will be used if we want to cache the portion of a page instead of whole page?
Fragment Caching: It caches the portion of the page generated by the request. For that, we can create user controls with the below code:
<%@ OutputCache Duration=”120″ VaryByParam=”CategorylD;SelectedlD”%>
List the events in page life cycle.
Can we have a web application running without web.Config file?
What is the difference between ASP.NET Webforms and ASP.NET MVC?
ASP.NET Webforms uses the page controller approach for rendering layout. In this approach, every page has its controller.
On the other hand, ASP.NET MVC uses the Front Controller approach. In this approach, there is a common controller for all pages.
Is it possible to create a web application with both webforms and MVC?
Yes. We have to include the below MVC assembly references in the web forms application to create a hybrid application.
System.Web.Mvc System.Web.Razor System. ComponentModel.DataAnnotations
Can we add code files of different languages in the App_Code folder?
No. The code files must be in the same language to be kept in the App_code folder.
What is Protected Configuration?
It is a feature used to secure connection string information.
Write code to send e-mail from an ASP.NET application?
MailMessage mailMess = new MailMessage ( ); mailMess.From = "email@example.com "; mailMess.To = "firstname.lastname@example.org"; mailMess.Subject = "Test email"; mailMess.Body = "Hi This is a test mail."; SmtpMail.SmtpServer = "localhost"; SmtpMail.Send (mailMess);
MailMessage and SmtpMail are classes defined System.Web.Mail namespace.
How can we prevent browser from caching an ASPX page?
We can SetNoStore on HttpCachePolicy object exposed by the Response object’s Cache property:
Response.Cache.SetNoStore ( );
Response.Write (DateTime.Now.ToLongTimeString ());
What is the good practice to implement validations in aspx page?
Client-side validation is the best way to validate data of a web page. It reduces the network traffic and saves server resources.
What is the use of Global.asax file?
The Global.asax file is used to execute the application-level events and sets application- level variables.
What is event bubbling?
When child control sends events to parent, it is termed as event bubbling. Server controls like Data Grid, Data List, and Repeater can have other child controls inside them.
What are the event handlers that we can have in Global.asax file?
Application Events: Application_Start, Application_End, Application_AcquireRequestState, Application_AuthenticateRequest, Application_AuthorizeRequest, Application_BeginRequest, Application_Disposed, Application_EndRequest, Application_Error, Application_PostRequestHandlerExecute, Application_PreRequestHandlerExecute,Application_PreSendRequestContent, Application_PreSendRequestHeaders, Application_ReleaseRequestState, Application_ResolveRequestCache, Application_UpdateRequestCache
Session Events: Session_Start,Session_End
Which protocol is used to call a Web service?
Can we have multiple web config files for an asp.net application?
What is the difference between web config and machine config?
Web config file is specific to a web application where as machine config is specific to a machine or server. There can be multiple web config files into an application where as we can have only one machine config file on a server.
Explain role based security ?
Role-based security is used in almost all organization, and the Role-based security assigns certain privileges to each role.
- Each user is assigned a particular role from the list.
- Privileges as per role restrict the user’s actions on the system and ensure that a user can do only what he is permitted to do on the system.
<AUTHORIZATION>< authorization > < allow roles="Domain_Name\Administrators" / > < !-- Allow Administrators in domain. — > < deny users-'*" /> < !-- Deny anyone else. -- > < /authorization >
What is Cross Page Posting?
When we click submit button on a web page, the page post the data to the same page. The technique in which we post the data to different pages is called Cross Page posting. This can be achieved by setting POSTBACKURL property of the button that causes the postback. Findcontrol method of PreviousPage can be used to get the posted values on the page to which the page has been posted.
How can we apply Themes to an asp.net application?
We can specify the theme in web.config file. Below is the code example to apply the theme:
<configuration> <system.web> <pages theme="Windows7" /> </system.web> </configuration>
What is RedirectPermanent in ASP.Net?
RedirectPermanent Performs a permanent redirection from the requested URL to the specified URL. Once the redirection is done, it also returns 301 Moved Permanently responses.
What is MVC?
MVC is a framework used to create web applications. The web application base builds on Model-View-Controller pattern which separates the application logic from Ul, and the input and events from the user will be controlled by the Controller.
Explain the working of passport authentication.
First of all it checks passport authentication cookie. If the cookie is not available then the application redirects the user to Passport Sign on page. Passport service authenticates the user details on sign on page and if valid then stores the authenticated cookie on client machine and then redirect the user to requested page
What are the advantages of Passport authentication?
All the websites can be accessed using single login credentials. So no need to remember login credentials for each web site.
Users can maintain his/ her information in a single location.
What are the asp.net Security Controls?
- <asp:Login>: Provides a standard login capability that allows the users to enter their credentials
- <asp:Loginl\lame>: Allows you to display the name of the logged-in user
- <asp:LoginStatus>: Displays whether the user is authenticated or not
- <asp:LoginView>: Provides various login views depending on the selected template
- <asp:PasswordRecovery>: email the users their lost password
In which event are the controls fully loaded?
Page load event.
what is boxing and unboxing?
Boxing is assigning a value type to reference type variable. Unboxing is reverse of boxing ie. Assigning reference type variable to value type variable.
Differentiate strong typing and weak typing
In strong typing, the data types of variable are checked at compile time. On the other hand, in case of weak typing the variable data types are checked at runtime. In case of strong typing, there is no chance of compilation error. Scripts use weak typing and hence issues arises at runtime.
How we can 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.
List all templates of the Repeater control.
List the major built-in objects in ASP.NET?
What is the appSettings Section in the web.config file?
The appSettings block in the web config 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:
<emxconfiguration> <appSettings> <add key-'ConnectionString" value="server=local; pwd=password; database=default" /> </appSettings></em>
Which data type does the RangeValidator control support?
The data types supported by the RangeValidator control are Integer, Double, String, Currency, and Date.
What is the difference between an HtmllnputCheckBox control and an HtmllnputRadioButton control?
In HtmllnputCheckBoxcontrol, multiple item selection is possible whereas in HtmllnputRadioButton controls, we can select only single item from the group of items.
Which namespaces are necessary to create a localized application?
What is a cookie?
A Cookie is a small piece of information which is stored at the client side. There are two types of cookie:
- Session/Temporary Cookie: valid for a single session
- Persistent Cookie: valid for multiple session
What is the default timeout for a cookie?
How would you turn off cookies on a page of a website?
You have to follow the procedures given below:
- Use the “Cookie.Discard” property,
- It gets or sets the discard flag set by the server.
- When set to true, this property instructs the client application not to save the Cookie on the hard disk of the user at the end of the session.
What are the different types of cookies in ASP.NET?
Session Cookie – Resides on the client machine for a single session until the user does not log out.
Persistent Cookie – Resides on a user’s machine for a period specified for its expiry, such as 10 days, one month, and never.
What is the file extension of web service?
Web services have file extension .asmx..
What are the components of ADO.NET?
The components of ADO.Net are Dataset, Data Reader, Data Adaptor, Command, connection.
What is the difference between ExecuteScalar and ExecuteNonQuery?
ExecuteScalar returns output value where as ExecuteNonQuery ctoes not return any value but the number of rows affected by the query. ExecuteScalar used for fetching a single value and ExecuteNonQuery used to execute Insert and Update statements.
What is IIS?
IIS stands for Internet Information Services. It is created by Microsoft to provide Internet-based services to ASP.NET Web applications.
What is the usage of IIS?
Following are the main usage of IIS:
- IIS is used to make 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,
- IIS also offers the services of SMTP and Frontpage server extensions.
- The SMTP is used to send emails and use Frontpage server extensions to get the dynamic features of IIS, such as form handler.
What is a multilingual website?
If a website provides content in many languages, it is known as a multilingual website. It contains multiple copies of its content and other resources, such as date and time, in different languages.
What is the parent class of all web server control?
System. Web. Ul.Control class
What is the difference between the GET method () and POST method ()?
Data is affixed to the URL.
Data is not secured.
Data transmission is faster in this method.
It is a single call system.
Only a limited amount of data can be sent.
It is a default method for many browsers.
Data is not affixed to the URL Data is secured.
Data transmission is comparatively slow
It is a two call system
A large amount of data can be sent
It is not set as default. It should be explicitly specified
What is the difference between session object and application object?
The session object is used to maintain the session of each user. A session id is generated if a user enters in the application and when the user leaves the application, the session id is automatically deleted.
On the other hand, the application object is used to store the information and access variables from any page in the application.
Debug class is used to debug builds. Trace class is used for both debug and release builds.
What is the difference between trace and debug?
Debug class is used to debug builds. Trace class is used for both debug and release builds.
What is the difference between client-side and server-side validations in WebPages?
What is the difference between file-based dependency and key-based dependency?
File-based dependency: File-based dependency facilitates you to save the dependency on a file in a disk.
Key-based dependency: In key-based dependency, you depend on another cached item.
What is the difference between globalization and localization?
Globalization: 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.
Localization: In localization, you try to configure a Web application so that it can be supported for a specific language or locale.
What is the difference between a page theme and a global theme?
Page Theme: The page theme is applied to particular web pages of the project. It is stored inside a subfolder of the App_Themes folder.
Global Theme: The Global theme is applied to all the web applications on the web server. It is stored inside the Themes folder on a Web server.
What is the difference between early binding and late binding?
Early Binding: In early binding, a non-virtual method is called which is decided at a compile time.
Late Binding: In late binding, a virtual method is called which is decided at runtime.
What is the difference between server-side scripting and client-side scripting?
Server-side scripting: In server-side scripting, all the script are executed by the server and interpreted as needed.
How to sign out from forms authentication?
FormsAuthentication.Signout() method is used to sign out from forms authentication.
How to display validation messages in one control?
By the help of ValidationSummary control, we can display all validation messages in one control.
What is the difference between authentication and authorization?
Authentication is a process of identifying user whereas authorization is used to check the access rights of an identified user.
Which object encapsulates state or data of a user?
What are the differences between the Response.Write() and Response.Output.Write()?
Response.Write( ) is used for normal output whereas Response.Output.Write() is used for formatted output.
Define the types of configuration files.
There are two types of configuration files:
- Application Level config = Web.config.
- Machine Level config = Machine.config.
What is the difference between Web config and Machine config files?
Web config file is specific to web application whereas Machine config file is specific to machine or server.
There can be multiple web config files in an application but only one machine config file.
What are the HTML server controls in ASP.NET?
- HTML server controls are just like HTML elements that we use on HTML pages.
- HTML server controls are used to expose properties and events for use.
- To make these controls programmatically accessible, we specify that the HTML controls act as a server control by adding the runat=Mserver” attribute.