Web config interview questions and answers asp.net
Today, In this tutorial I am going to talk about asp.net web.config file and its uses, we will also talk about the FAQ of web config, which is asked in asp.net interview. As shown by the name "wen.config" it means web configuration. Where we can do custom configuration like URL Rewriting, Authentication and authorization, connection and all. So let's see how it works and the important question which is asked during the interview.
Some main work of web.config file
- Custom error configuration (for 404, 403, other error of application)
- Database connection configuration.
- Error handling.
- Url rewriting.
- Declaration of variables (key) -- For global use in the application.
Web config interview questions
Q.1) What is a web.config file.
Ans: Web. Config is an application configuration file of asp.net application which is written in XML Format. Every root directory has only one web config file. We can have multiple web config files in our asp.net application there is no restriction to use the web.config file.
Q.2) Does web.config file case-sensitive?
Q.3) What is the format of the web.config file.
Ans: XML Format.
Q.4) Can the ASP.NET project run without a Web.config file?
Ans: Yes we can run.
Q.5) Can we have multiple web.config in one application
Ans: Yes, we can have multiple web config in one application, but one directory can contain only one web config.
Q.6) How you will configure the connection for the database in web config?
Ans: By adding the <connectionstring> </connectionstring> tag, later on we will configure our connection between these tag.
<add name="mydatabasename" connectionString="Data Source=.;Initial Catalog=list4business;Integrated Security=true; timeout=10000;" />
In the above <connectionStrings> we have multiple attributes in <add> tag. let's know about each part on the above connection line.
name is used for the connection name, later with help of this name we can call our connection string.
connectionString is used for the connection with the database (SQL, Oracle). In connectionString we have Data Source, Initial Catalog, Integrated security.
Q.7) Write the syntax of app setting in web config.
Ans: In App setting we can add values in key-value format and later on we can use it multiple times according to our requirement.
<add key="registration_email_id" value="[email protected]" />
How to use appsetting in cs page of application.
email_id = ConfigurationSettings.AppSettings[
Q.8) Can we set the startup page on the web.config file.
Ans: We can set startup page on web config by using some code. First, find the System.webserver in web config and write the following code within <</
In the Above source code index.aspx will be your startup page.
Q.9) How to Use Web. Config customErrors for ASP.NET.
Ans: In asp.net application customErrors support mainly 3 types of modes.
I hope you like this "Web config interview questions". Please don't forget to comment below. If you found it to be helpful.