www.w3asp.net
TOP 20 INTERVIEW
QUESTION AND ANSWERS
www.w3asp.net
1. What are namespaces, and how they are used?
Ans. Namespaces are used to organize classes within the .NET
Framework. They dictate the logical structure of the code. The .NET
Framework has namespaces defined for its many classes, such as
System.Xml—these are utilized via the using statement. Namespaces
are assigned to classes via the namespace keyword.
2. How can I run an application with and without
debugger?
Ans. To run the application with debugger, select Debug > Run or
press F5. To run the application without debugger, select Debug >
Run without debugger or press Ctrl+F5
www.w3asp.net
3. What are break points in context with the debugger?
Ans. A break point is the line of code at which you want your program
to be paused (when running in debugger mode) and see the runtime
values of different variables in the program. If the program control
ever reaches this line during the execution of the program, it pause
the execution and allows you to see and edit the values of the
variables of your program.
4. What base class do all Web Forms inherit from ?
Ans. System.Windows.Forms.Form
www.w3asp.net
5. What is a digital signature?
Ans. A digital signature is an electronic signature used to
verify/guarantee the identity of the individual who is sending the
message.
6. What is a IL?
Ans. (IL)Intermediate Language is also known as MSIL (Microsoft
Intermediate Language) or CIL (Common Intermediate Language).
All .NET source code is compiled to IL. This IL is then converted to
machine code at the point where the software is installed, or at run-
time by a Just-In- Time (JIT) compiler.
www.w3asp.net
7. How do I sign out in forms authentication?
Ans. FormsAuthentication.Signout ()
8. How you can disable session in Asp.net?
Ans. If we set session Mode=”off” in web.config file, session will be
disabled in the application. For this we need to configure web.config
in the following way:
<Configuration>
<sessionmode="off"/>
</configuration>
www.w3asp.net
9. What classes are needed to send e-mail from an
ASP.NET application?
Ans. The classes MailMessage and SmtpMail have to be used to send
email from an ASP.NET application. MailMessage and SmtpMail are
classes defined in the .NET Framework Class Library(s)
System.Web.Mail namespace.
10. How do you turn off cookies for one page in your
site?
Ans. Use the Cookie.Discard Property which Gets or Sets the discard
flag set by the server. When true, this property instructs the client
application not to save the Cookie on the hard disk when a session
ends.
www.w3asp.net
11. How is .NET able to support multiple languages?
Ans. A language should comply with the Common Language Runtime
(CLR) standard to become a .Net language. In .Net, code is compiled
to Microsoft Intermediate Language (MSIL). This is called as Managed
Code. This Managed code is run in .Net environment. So after
compilation to this IL the language is not a barrier. A code can call or
use a function written in another language.
12. How to access HTTP-Specific information from within
a class (.cs File)
Ans. Add reference to the System.Web assembly in your class and
use the Current property of the HttpContext object to access the
desired server variable. Like -
string value = (string)(HttpContext.Current.Session["someData"]);
www.w3asp.net
13. What are the various ways of securing a web site that
could prevent from unwanted uses?
Ans. 1 Authentication/Authorization
2 Encryption/Decryption
3 Maintaining web servers outside the corporate firewall.
14. What is the Garbage Collection in ASP.Net ?
Ans. GC is the process whereby the Common Language Runtime
(CLR) reclaims memory that is no longer in use—i.e., no longer
referenced by an active object. Objects on the heap are garbage
collected after the final reference to them is destroyed. The exact
moment of collection is determined by the CLR. Memory for stack
values is freed up immediately when the stack frame in which they
are declared ends—e.g., when a method returns.
www.w3asp.net
15. What is the state management? What is the use of
state management in ASP.Net ?
Ans. State management is nothing but maintaining the user
information on client side or sever side. There are two types of state
management -
1. Server side state management - Session, Application, Caching,
Profiles.
2. Client side state management - Query string, Hidden field,
Cookies, Viewstates.
16. What is a control?
Ans. A control is a component that provides user-interface (UI)
capabilities.
www.w3asp.net
17. What is the role of Global.asax file?
Ans. Stores Global information about the application.
18. What is the difference between ExecuteQuery() and
ExecuteNonQuery()?
Ans. ExecuteQuery : Executes SQL queries directly on the database.
It has two overlaoded method:
1. DataContext.ExecuteQuery(TResult)(String, Object[]) - Executes
SQL queries directly on the database and returns objects.
2. ExecuteQuery(Type, String, object[]) - Executes SQL queries
directly on the database.
ExecuteNonQuery : Use for data manipulation, such as Insert,
Update, Delete.
www.w3asp.net
19.Explain the types of errors.
Ans. Syntax Errors: These include misspelled or missing keywords, or
other mistakes relating to the syntax of the language.
Runtime Errors: These errors are caused by the code that appears
correct to the compiler, but that cannot run with certain values
Logic Errors: These are errors in which a program that works
correctly under some circumstances give unexpected or unwanted
results based on certain input.
20. What is the root namespace for all types?
Ans. System.
www.w3asp.net
FOR MORE VISIT: www.w3asp.net

Top 20 Asp.net interview Question and answers

  • 1.
  • 2.
    www.w3asp.net 1. What arenamespaces, and how they are used? Ans. Namespaces are used to organize classes within the .NET Framework. They dictate the logical structure of the code. The .NET Framework has namespaces defined for its many classes, such as System.Xml—these are utilized via the using statement. Namespaces are assigned to classes via the namespace keyword. 2. How can I run an application with and without debugger? Ans. To run the application with debugger, select Debug > Run or press F5. To run the application without debugger, select Debug > Run without debugger or press Ctrl+F5
  • 3.
    www.w3asp.net 3. What arebreak points in context with the debugger? Ans. A break point is the line of code at which you want your program to be paused (when running in debugger mode) and see the runtime values of different variables in the program. If the program control ever reaches this line during the execution of the program, it pause the execution and allows you to see and edit the values of the variables of your program. 4. What base class do all Web Forms inherit from ? Ans. System.Windows.Forms.Form
  • 4.
    www.w3asp.net 5. What isa digital signature? Ans. A digital signature is an electronic signature used to verify/guarantee the identity of the individual who is sending the message. 6. What is a IL? Ans. (IL)Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code is compiled to IL. This IL is then converted to machine code at the point where the software is installed, or at run- time by a Just-In- Time (JIT) compiler.
  • 5.
    www.w3asp.net 7. How doI sign out in forms authentication? Ans. FormsAuthentication.Signout () 8. How you can disable session in Asp.net? Ans. If we set session Mode=”off” in web.config file, session will be disabled in the application. For this we need to configure web.config in the following way: <Configuration> <sessionmode="off"/> </configuration>
  • 6.
    www.w3asp.net 9. What classesare needed to send e-mail from an ASP.NET application? Ans. The classes MailMessage and SmtpMail have to be used to send email from an ASP.NET application. MailMessage and SmtpMail are classes defined in the .NET Framework Class Library(s) System.Web.Mail namespace. 10. How do you turn off cookies for one page in your site? Ans. Use the Cookie.Discard Property which Gets or Sets the discard flag set by the server. When true, this property instructs the client application not to save the Cookie on the hard disk when a session ends.
  • 7.
    www.w3asp.net 11. How is.NET able to support multiple languages? Ans. A language should comply with the Common Language Runtime (CLR) standard to become a .Net language. In .Net, code is compiled to Microsoft Intermediate Language (MSIL). This is called as Managed Code. This Managed code is run in .Net environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language. 12. How to access HTTP-Specific information from within a class (.cs File) Ans. Add reference to the System.Web assembly in your class and use the Current property of the HttpContext object to access the desired server variable. Like - string value = (string)(HttpContext.Current.Session["someData"]);
  • 8.
    www.w3asp.net 13. What arethe various ways of securing a web site that could prevent from unwanted uses? Ans. 1 Authentication/Authorization 2 Encryption/Decryption 3 Maintaining web servers outside the corporate firewall. 14. What is the Garbage Collection in ASP.Net ? Ans. GC is the process whereby the Common Language Runtime (CLR) reclaims memory that is no longer in use—i.e., no longer referenced by an active object. Objects on the heap are garbage collected after the final reference to them is destroyed. The exact moment of collection is determined by the CLR. Memory for stack values is freed up immediately when the stack frame in which they are declared ends—e.g., when a method returns.
  • 9.
    www.w3asp.net 15. What isthe state management? What is the use of state management in ASP.Net ? Ans. State management is nothing but maintaining the user information on client side or sever side. There are two types of state management - 1. Server side state management - Session, Application, Caching, Profiles. 2. Client side state management - Query string, Hidden field, Cookies, Viewstates. 16. What is a control? Ans. A control is a component that provides user-interface (UI) capabilities.
  • 10.
    www.w3asp.net 17. What isthe role of Global.asax file? Ans. Stores Global information about the application. 18. What is the difference between ExecuteQuery() and ExecuteNonQuery()? Ans. ExecuteQuery : Executes SQL queries directly on the database. It has two overlaoded method: 1. DataContext.ExecuteQuery(TResult)(String, Object[]) - Executes SQL queries directly on the database and returns objects. 2. ExecuteQuery(Type, String, object[]) - Executes SQL queries directly on the database. ExecuteNonQuery : Use for data manipulation, such as Insert, Update, Delete.
  • 11.
    www.w3asp.net 19.Explain the typesof errors. Ans. Syntax Errors: These include misspelled or missing keywords, or other mistakes relating to the syntax of the language. Runtime Errors: These errors are caused by the code that appears correct to the compiler, but that cannot run with certain values Logic Errors: These are errors in which a program that works correctly under some circumstances give unexpected or unwanted results based on certain input. 20. What is the root namespace for all types? Ans. System.
  • 12.