ASP.NET Interview Questions with Answers

In this series of tutorial I will list some important .net interview questions with answers which are generally asked in written or verbal technical interviews from .net developers by majority of IT Companies. These ASP.Net interview questions are suitable for candidates who are applying as a fresher  or having more than 2 years, 3 years, 4 years or 5 Years of experience. Most of the questions which are given here are those which are asked in real interviews and some of the questions are those which are more likely to be asked by many Software Companies during selection process. All readers are advised to study the detailed answers of listed questions here from other sites as well so they get clear concept of each question.

I also request readers to provide more questions which are asked from them when they applied for the job in an IT Company , so it can benefit others as well.

1. What are maximum number of cookies per website in web application?

Answer: 20 cookies

2. Which Namespace is used for custom controls in
Answer: System.Web.UI.Control

3. Which namespace used for session state in
Answer: System.Web.SessionState

4. Which is not method of Response object:
(b) Response.End()
(c) Response.Clear()
(d) Response.Execute()

Answer: Response.Execute()

5. Does repeater has automatic paging?
Answer :No

6. Does grid view control in support pagination?
Answer :Yes (set AllowPaging property to True)

7. Is it possible to set max length of text box control in code behind?
Answer :Yes.( textBox1.MaxLength = 5).

8. What is default value for EnableViewState Property of server control?

Answer: True

9. What is view State?

Answer: View state let the controls to maintain its state during postbacks( Http Request). 

10. What is Response.End() in

Answer: Response.End() stop the execution of the page and raise the EndRequest Event. 

11. By which web protocol a web service is accessible?

Answer: SOAP(Simple Object Access Protocol)

12. Which namespace is used for all server control in

Answer: System.Web.UI.WebControls 

13. Namespace for ConnectionString property.

Answer: System.Configuration

14. Namespace for DataSet.

Answer: System.Data

15. NameSpace for WebServices in

Answer: System.Web.Services

16. Namespace for WCF services in

Answer: System.ServiceModel

17. Namespace used for SqlConnection in

Answer: System.Data.SqlClient

18. Namespace for List in

Answer: System.Collections.Generic.

19. Namespace for DbContext in Entity Framework.
Answer: System.Data.Entity

20. Which namespace used for Request, Response, Application and Server object in

Answer: System.Web

21. Namespace used for authentication such as Windows Authentication, Passport Authentication or Form Authentication.

Answer: System.Web.Security

22. Which namespace is used to send email using SMTP Protocol in

Answer: System.Net.Mail namespace is used to send email. This namespace contain classes such as MailMessage, SmtpClient etc.

23. Difference between System.Web.Mail and System.Net.Mail namespace.

Answer: Both namespace used to send email in application. System.Web.Mail namespace used in .Net Framework 1.0 while System.Net.Mail is used in .Net Framework 2.0 and higher. System.Net.Mail namespace has more functionality compared to System.Web.Mail namespace.

Web.Configuration Interview Questions:

1.Can an application have more than one Web.Config File?
Answer: Yes a web application can have more than one web.config files.

2. What is format of Web.Config File?
Answer:Xml format.

3. Does a directory can have multiple web.config files?
Answer: No , a directory can have single web.config file.

4. How do you specify connection string in Web.config file?
Answer: <connectionStrings>
    <add name="ApplicationServices"
         connectionString="Data Source=Server Name;Initial Catalog=Database Name;User ID=sa;Password=123"
         providerName="System.Data.SqlClient" />

5. How do you read connection string from Web.Config File?
Answer: SqlConnection con=new SqlConnection(ConfigurationManager.ConnectionStrings["name of connection string in web.config file"].ToString());

6.What is <appsettings> tag in Web.Config file?
Answer: :<appsettings> tag is used to specify key value value pair which can be accessed throughout the application.

Syntax: <appSettings>
              <add key="test" value="This is testing value"/>

7. How read app setting value from web.config file?
Answer: string myname = ConfigurationManager.AppSettings["test"].ToString();

8. How to specify session time out in web.config?
Answer: : Default session timeout is 20 minutes for a web application. You can change session time in <sessionState> tag.

Syntax: <sessionState timeout="30"></sessionState>

Here timeout value is in minutes. 

9. What is meaning of <customErrors> tag in web.config?
Answer: CustomErrors can be used to specify what information would be shown if some un-handled error occur during the execution.
CustomError Mode can be of 3 types:
(a) <customErrors mode="on">:Custom error are enabled. Custom Error would be shown to remote client and local host.
(b) <customErrors mode="off">: custom error disabled but error would be shown to local host and remote client.
(c) <customErrors mode="remoteonly">: This is default mode . Custom errors would be shown to the remote client while error would be shown to local host.

10. What is default authentication mode  in Web.config file?
Answer: Windows Authentication. <authentication mode="Windows/>

11. How to enable or disable view state in Web.config file.
Answer<pages enableViewState="false"></pages>: This will disable  viewstate.
             <pages enableViewState="true"></pages>:This will enable viewstate.

12. What are different type of SessionState mode in Web.config file?
Answer:(a) Custom
            (b) InProc
            (c) SqlServer
            (d) StateServer
            (e) Off

13. In which tag you can specify the email setting for your web application.
Answer: < >.

14. Does Web server need to be rebooted if any change is made in web.config file?
Answer: No , server is not need to be restarted if any change is made in web.config file. Only <processmodel> tag is the exception. Change made inside this tag are not implemented until the server is restarted.

15. What would happen if you try to open web.config file in browser?
Answer: IIS prevent web.config file to be browsed in any browser. If you try to open web.config file in browser error HTTP Error 403 would be returned.

16. Does tag of web.config file are case sensitive?
Answer: Yes tags contained in web.config file are case sensitive.

17. Which is the root tag of Web.Config file?
Answer: <configuration></configuration>

18. How to redirect user from old website address to new website address?
Answer: <system.webServer>
      <httpRedirect destination="" enabled="true">
   It will redirect all the url to

  19. How to enable directory browsing in web.config file?
  Answer: <system.webServer>    
  <directoryBrowse enabled="true"/>

 20. How to open default page using web.config file?
 Answer: <system.webServer>       
    <defaultDocument enabled="true">
      <add value="test.html"/>

  21. How to redirect user to custom error page using web.config file?
  Answer:  <system.webServer>
  <httpErrors errorMode="Custom" >
    <remove statusCode="404" subStatusCode='-1' />
    <remove statusCode="500" subStatusCode='-1' />
    <error statusCode="404" path="/error.html" prefixLanguageFilePath="" responseMode="ExecuteURL"  />
    <error statusCode="500" path="/error.html" prefixLanguageFilePath="" responseMode="ExecuteURL" />  

  22. How to increase default file upload size limit in web.config file?
  Answer: <configuration>
    <httpRuntime maxRequestLength="enter limit in kb" />
The defualt file upload size is 4MB.

ADO.Net Interview Questions with Answers:

1. What is
Answer: ADO stands for AcitveX Data Object. ADO.Net is the part of .net framework , it contain classes to provide connectivity with  various data sources such as relational, xml and application data.

2. Which are the various data provider in
Answer: In there are different data provider to connect with particular type of database. The list of data provider in is as follow:
(a) provider for MSSQL connectivity: System.Data.SqlClient
(b) Data Provider for OLE DB :(System.Data.OleDb) can be used to connect with MSAccess database etc.
(c) Data Provider with Oracle Database: System.Data.OracleClient
(d) ODBC data provider: System.Data.Odbc

3. Name two main objects in ADO.Net?
Answer: (a) DataReader
              (b) DataSet

4. Which method of adapter is used to fill data in DataSet Object?
Answer: Fill() method.

5. Which namespace used for SqlDataAdapter class?
Answer: System.Data.SqlClient

6. Which namespace used for DataSet class?
Answer: System.Data.

7. What does SqlCommnad represent?
Answer: SqlCommand is contained in the namespace System.Data.SqlClient. It represent Sql Query or Stored Procedure to be executed against database.

8. What is DataSet in
Answer: DataSet represents in memory cache of data. It follows disconnected approach in which connection to database is kept open till data retrieved from database and later data can be accessed even if the connection to database is closed. A DataSet contain collection of 0 or more tables.

9. Explain DataReader in
Answer: Data Reader provide way of reading forward-only stream of rows from Database. DataReader is efficient while reading a large amount of data as it do not cache data in memory compared to DataSet. DataReader follows Connected approach in which connection must be kept open till the end of retrieval and access of data from database.

10. Which property is used to check  if DataReader contain rows or not?
Answer: HasRows .

11. Which method of DataReader used to read rows returned by query from database?
Answer: Read() method is used to read rows one by one from DataReader.

12. Explain adp.Fill() method of DataAdapter.
Answer: Fill() method of DataAdapter is used to populate DataSet with values.

13. Which are the different commands of DataAdapter in
Answer: The following are the commands used with DataAdapter:
(a) SelectCommand: Get or set Sql Statement or stored procedure used to select record in data source.
(b) DeleteCommand: Get or set Sql Statement or stored procedure to delete record from data set.
(c) InsertCommand: Get or set Sql Statement or stored procedure to insert new record in the data source.
(d) UpdateCommand: Get or set Sql Statement or stored procedure to update records in data source.

14. Which property of DataAdapter return columns count in a row?
Answer: FieldCount return number of column in current row.

15. Which method is used to get the name of specified column in DataReader?
Answer: GetName() method is used to get the name of column in data reader.

16. What is the difference between ExecuteScalar(), ExecuteReader() and ExecuteNonQuery() Methods?
Answer: ExecuteScalar() method will return single value after executing sql query or stored procedure.

ExecuteReader() method will return the set of rows from database after execution of stored procedure or sql query.

ExecuteNonQuery() method will return an integer for number rows affected after insert , update or delete operation on database.

17. Which is the default provider to access database ?
Answer: System.Data.SqlClient()

18. In which namespace ConnectionStrings property comes under?
Answer: System.Configuration


  1. I really love reading and following your post as I find them extremely informative and interesting. This post is equally informative as well as interesting . Thank you for information you been putting on making your site such an interesting. I gave something for my information. Interview Preparation

  2. I think its good document for interview preparation keep it up.

  3. Thanks for sharing such informative article.
    .Net Training in Chennai

  4. Thank for sharing an highly informative post.. It will helpful for the beginners to enrich their knowledge.


    Internship in Chennai

  5. nice and really helpful article to everyone... thanks for sharing.
    apple-ios training in chennai

  6. Great post and informative was awesome to read, thanks for sharing this great content to my vision.
    informix training in chennai

  7. This comment has been removed by the author.

  8. This comment has been removed by the author.

  9. • Great post and informative was awesome to read, thanks for sharing this great content to my vision..
    websphere training in chennai

  10. • Its really helpful for me. Suppose if anyone want to find real time coaching center.recently i did some blog may visit..
    microstrategy training in chennai

  11. very informative & stunning interview hacking. keep sharing Best ASP .Net Training in Chennai

  12. Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..

    iOS Training in Chennai

  13. Hi, the information you provided here is very informative and useful for me. If anyone interested to learn AngularJS Training reach GangBoard. MSBI Training | Hadoop Training

  14. The interview questions shared are very much useful Thanks for sharing it
    Hadoop Training in Chennai

  15. Nice blog. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it. erp software in chennai.

  16. thank you for such a great article with us. hope it will be much useful for us. please keep on updating..
    Web designing course in chennai

  17. hi welcome to this blog. really you have post an informative blog. it will be really helpful to many peoples. thank you for sharing this blog.
    android training in chennai

  18. wow.Bundle of question & answers.Thank you so much for sharing.
    Android Training in Chennai |
    Dot Net Training in Chennai

  19. Really an amazing post..! By reading your blog post i gained more information.
    Bulk SMS Chennai
    Internet Marketing Company Chennai

  20. The dotnet interview questions shared are very much useful My sincere thanks for sharing this post and please continue to share this post
    Dot Net Training in Chennai

  21. Good and nice information, thanks for sharing your views and ideas.. keep rocks and updating..

    Dot Net Training in chennai

  22. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
    Android Training in Chennai
    Ios Training in Chennai

  23. The website is looking bit flashy and it catches the visitors eyes. A design is pretty simple .
    regionale stellenbörse

  24. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    dot-net training in chennai

  25. I wish to indicate because of you only to bail me out of this specific trouble.As a consequence of checking through the net and meeting systems that were not beneficial, I thought my life was finished.
    Dotnet Training in Marathahalli

  26. This post had my attention all the way, do keep the great content coming! If you ever need help to register a business, check out the best business incorporation assistant now! accounting company immediately!

  27. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
    digital training in chennai

  28. Interesting post! This is really helpful for me. I like it! Thanks for sharing!
    Mobile application developers in Chennai | PHP developers Chennai

  29. Nice post about MSBI, are you looking for best msbi online training.

  30. This comment has been removed by the author.

  31. Thank you a lot for providing individuals with a very
    spectacular possibility to read critical reviews from this site.
    selenium training in chennai

  32. I simply wanted to thank you so much again. I am not sure the things that I might have gone through without the type of hints revealed by you regarding that situation.

    Selenium Training in Bangalore

  33. That's a good perspective for the expensive price. It probably is worth paying since I can see movies in English here!
    MCA Project Center in Chennai | MCA Project Center in Velachery

  34. I wish to show thanks to you just for bailing me out of this particular
    trouble.As a result of checking through the net and meeting
    techniques that were not productive, I thought my life was done.

    java training in chennai

    java training in bangalore

  35. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
    big data training in bangalore

  36. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

    dotnet training in bangalore

  37. Thanks for your information sharing with us, We are waiting for your more updates on MSBI Online Training Bangalore

  38. Your new valuable key points imply much a person like me and extremely more to my office workers. With thanks.

    Hadoop online Training|Informatica Online Training|ETL Testing Online Training

  39. Excellent information got from this blog. Thanks for sharing .NET questions try to post on .net ajax too.
    ASP.NET Online Training | ASP.NET MVC Training


  40. Your blog is very nice and information you provided really cool. pm blog

  41. Thanks for sharing this niche useful informative post to our knowledge.
    brochure designers in chennai | brochure design company in chennai

  42. I wanted to thank you for this great read!! I absolutely loved every little bit of it.
    I have you saved as a favorite to look at new things you post…
    Good Summer Courses for Hardware Networking | Best Summer Course in Chennai

  43. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
    Authorized dotnet training in bangalore

  44. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.