Showing posts with label asp interview questions. Show all posts
Showing posts with label asp interview questions. Show all posts

ASP .Net Interview Questions

1)How does ViewState work and why is it either useful or evil?
2)What is the OO relationship between an ASPX page and its CS/VB code behind file in ASP.NET 1.1? in 2.0?
3)What is an assembly binding redirect? Where are the places an administrator or developer can affect how assembly binding policy is applied?
  1. Compare and contrast LoadLibrary(), CoCreateInstance(), CreateObject() and Assembly.Load().
  2. What happens from the point an HTTP request is received on a TCP/IP port up until the Page fires the On_Load event?
  3. What are ASHX files?  What are HttpHandlers?  Where can they be configured?
  4. What is needed to configure a new extension for use in ASP.NET? For example, what if I wanted my system to serve ASPX files with a *.jsp extension?
  5. What events fire when binding data to a data grid? What are they good for?
  6. How does IIS communicate at runtime with ASP.NET?  Where is ASP.NET at runtime in IIS5? IIS6?
  7. Explain how PostBacks work, on both the client-side and server-side. How do I chain my own JavaScript into the client side without losing PostBack functionality?

IBM interview questions for ASP DOTNET questions

IBM interview questions for ASP DOTNET questions
1)How many objects are there in ASP?
2)Which DLL file is needed to be registered for ASP?
3)If you want to initialize a global variable for an application, which is the right place to declare it? (like form or some other file).
4)What is diffrence between Server.transfer and Response.redirect.
5)Is there any inbuilt paging(for example shoping cart. which will show next 10 records without refreshing) in ASP? How will you do pating.
6)What does Server.MapPath do?
7)Name at least three methods of response object other than Redirect.
8)Name at least two methods of response object other than Transfer.
9)Tell few programming diffrence between ADO and DAO programming. What is state?
10)How many types of cookies are there?
11)Tell few steps for optimizing (for speed and resources) ASP page/application .

C# interview questions on Destructors

C# interview questions on Destructors

What is a Destructor?
A Destructor has the same name as the class with a tilde character and is used to destroy an instance of a class.

Can a class have more than 1 destructor?

No, a class can have only 1 destructor.

Can structs in C# have destructors?
No, structs can have constructors but not destructors, only classes can have destructors.

Can you pass parameters to destructors?
No, you cannot pass parameters to destructors. Hence, you cannot overload destructors.

Can you explicitly call a destructor?

No, you cannot explicitly call a destructor. Destructors are invoked automatically by the garbage collector.

Why is it not a good idea to use Empty destructors?
When a class contains a destructor, an entry is created in the Finalize queue. When the destructor is called, the garbage collector is invoked to process the queue. If the destructor is empty, this just causes a needless loss of performance.

Is it possible to force garbage collector to run?
Yes, it possible to force garbage collector to run by calling the Collect() method, but this is not considered a good practice because this might create a performance over head. Usually the programmer has no control over when the garbage collector runs. The garbage collector checks for objects that are no longer being used by the application. If it considers an object eligible for destruction, it calls the destructor(if there is one) and reclaims the memory used to store the object.

Usually in .NET, the CLR takes care of memory management. Is there any need for a programmer to explicitly release memory and resources? If yes, why and how?
If the application is using expensive external resource, it is recommend to explicitly release the resource before the garbage collector runs and frees the object. We can do this by implementing the Dispose method from the IDisposable interface that performs the necessary cleanup for the object. This can considerably improve the performance of the application.

When do we generally use destructors to release resources?
If the application uses unmanaged resources such as windows, files, and network connections, we use destructors to release resources.

Keywords:
destructor in c# tutorialspoint
constructor and destructor in c#
c# destructor vs dispose
c# destructor not called
destructor in c# in hindi
difference between constructor and destructor in c++
c# destructor vs finalize
virtual destructor in c# net
c# destructor not called
c# finalizer vs destructor
c# static destructor
c# struct constructor
c# form destructor
c# force destructor call
c++ struct destructor
finalize c#
c# destructor not called
c# destructor vs dispose
c# destructor vs finalize
constructor and destructor in c#
destructor in c# tutorialspoint
c# struct destructor
c# static destructor
c# when is destructor called

ASP.NET Interview questions and answers for interfaces

ASP.NET Interview questions and answers for  interfaces

Explain what is an Interface in C#?
An Interface in C# is created using the interface keyword. An example is shown below.
using System;
namespace Interfaces
{
   interface IBankCustomer
   {
      void DepositMoney();
      void WithdrawMoney();
   }
   public class Demo : IBankCustomer
   {
      public void DepositMoney()
      {
         Console.WriteLine("Deposit Money");
      }

      public void WithdrawMoney()
      {
         Console.WriteLine("Withdraw Money");
      }

      public static void Main()
      {
         Demo DemoObject = new Demo();
         DemoObject.DepositMoney();
         DemoObject.WithdrawMoney();
      }
   }
}
In our example we created IBank Customer interface. The interface declares 2 methods.
1. void DepositMoney();
2. void WithdrawMoney();

Notice that method declarations does not have access modifiers like public, private, etc. By default all interface members are public. It is a compile time error to use access modifiers on interface member declarations. Also notice that the interface methods have only declarations and not implementation. It is a compile time error to provide implementation for any interface member. In our example as the Demo class is inherited from the IBankCustomer interface, the Demo class has to provide the implementation for both the methods (WithdrawMoney() and DepositMoney()) that is inherited from the interface. If the class fails to provide implementation for any of the inherited interface member, a compile time error will be generated. Interfaces can consist of methods, properties, events, indexers, or any combination of those four member types. When a class or a struct inherits an interface, the class or struct must provide implementation for all of the members declared in the interface. The interface itself provides no functionality that a class or struct can inherit in the way that base class functionality can be inherited. However, if a base class implements an interface, the derived class inherits that implementation.

Can an Interface contain fields?
No, an Interface cannot contain fields.

What is the difference between class inheritance and interface inheritance?
Classes and structs can inherit from interfaces just like how classes can inherit a base class or struct. However there are 2 differences.
1. A class or a struct can inherit from more than one interface at the same time where as A class or a struct cannot inherit from more than one class at the same time. An example depicting the same is shown below.
using System;
namespace Interfaces
{
   interface Interface1
   {
      void Interface1Method();
   }
   interface Interface2
   {
      void Interface2Method();
   }
   class BaseClass1
   {
      public void BaseClass1Method()
      {
         Console.WriteLine("BaseClass1 Method");
      }
   }
   class BaseClass2
   {
      public void BaseClass2Method()
      {
         Console.WriteLine("BaseClass2 Method");
      }
   }

   //Error : A class cannot inherit from more than one class at the same time
   //class DerivedClass : BaseClass1, BaseClass2
   //{
   //}

   //A class can inherit from more than one interface at the same time
   public class Demo : Interface1, Interface2
   {
      public void Interface1Method()
      {
         Console.WriteLine("Interface1 Method");
      }

      public void Interface2Method()
      {
         Console.WriteLine("Interface2 Method");
      }

      public static void Main()
      {
         Demo DemoObject = new Demo();
         DemoObject.Interface1Method();
         DemoObject.Interface2Method();
      }
   }
}
2. When a class or struct inherits an interface, it inherits only the method names and signatures, because the interface itself contains no implementations.

Can an interface inherit from another interface?
Yes, an interface can inherit from another interface. It is possible for a class to inherit an interface multiple times, through base classes or interfaces it inherits. In this case, the class can only implement the interface one time, if it is declared as part of the new class. If the inherited interface is not declared as part of the new class, its implementation is provided by the base class that declared it. It is possible for a base class to implement interface members using virtual members; in that case, the class inheriting the interface can change the interface behavior by overriding the virtual members.

Can you create an instance of an interface?
No, you cannot create an instance of an interface.

If a class inherits an interface, what are the 2 options available for that class?
Option 1: Provide Implementation for all the members inheirted from the interface.
namespace Interfaces
{
   interface Interface1
   {
      void Interface1Method();
   }

   class BaseClass1 : Interface1
   {
      public void Interface1Method()
      {
         Console.WriteLine("Interface1 Method");
      }
      public void BaseClass1Method()
      {
         Console.WriteLine("BaseClass1 Method");
      }
   }
}
Option 2: If the class does not wish to provide Implementation for all the members inheirted from the interface, then the class has to be marked as abstract.
namespace Interfaces
{
   interface Interface1
   {
      void Interface1Method();
   }

   abstract class BaseClass1 : Interface1
   {
      abstract public void Interface1Method();
      public void BaseClass1Method()
      {
         Console.WriteLine("BaseClass1 Method");
      }
   }
}
A class inherits from 2 interfaces and both the interfaces have the same method name as shown below. How should the class implement the drive method for both Car and Bus interface?
namespace Interfaces
{
   interface Car
   {
      void Drive();
   }
   interface Bus
   {
      void Drive();
   }

   class Demo : Car,Bus
   {
      //How to implement the Drive() Method inherited from Bus and Car
   }
}
To implement the Drive() method use the fully qualified name as shown in the example below. To call the respective interface drive method type cast the demo object to the respective interface and then call the drive method.
using System;
namespace Interfaces
{
   interface Car
   {
      void Drive();
   }
   interface Bus
   {
      void Drive();
   }

   class Demo : Car,Bus
   {
      void Car.Drive()
      {
         Console.WriteLine("Drive Car");
      }
      void Bus.Drive()
      {
         Console.WriteLine("Drive Bus");
      }

      static void Main()
      {
         Demo DemoObject = new Demo();
         ((Car)DemoObject).Drive();
         ((Bus)DemoObject).Drive();
      }
   }
}

What do you mean by "Explicitly Implementing an Interface". Give an example?
If a class is implementing the inherited interface member by prefixing the name of the interface, then the class is "Explicitly Implemeting an Interface member". The disadvantage of Explicitly Implemeting an Interface member is that, the class object has to be type casted to the interface type to invoke the interface member. An example is shown below.
using System;
namespace Interfaces
{
   interface Car
   {
      void Drive();
   }

   class Demo : Car
   {
      // Explicit implementation of an interface member
      void Car.Drive()
      {
         Console.WriteLine("Drive Car");
      }

      static void Main()
      {
         Demo DemoObject = new Demo();

         //DemoObject.Drive();
         // Error: Cannot call explicitly implemented interface method
         // using the class object.
         // Type cast the demo object to interface type Car
         ((Car)DemoObject).Drive();
      }
   }
}

Keywords:
interface in c# with example code project
types of interface in c#
interface in c# with real time example
multiple interface in c#
interface in c# interview questions
interface in c# tutorialspoint
difference between abstract class and interface in c#
c# interface property
interface inheritance c#
difference between abstract class and interface in c#
types of interface in c#
c# instantiate interface
interface inheritance vs implementation inheritance
interface with implementation c#
c# struct interface
single inheritance in c#
c# interface tutorial
types of interface in c#
c# interface inheritance override
c# interface constructor
c# interface property
interface in c# with example code project
multiple interface in c#
c# multiple inheritance
can we create instance of interface in c#
can we create instance of interface in java
can we create object of interface in java 8
interface instance c#
many classes can implement the same interface
can we create object for interface
can we create instance of abstract class
a class can implement multiple interfaces
c# interface
tricky question on interface in c#
use of interface in c#
interface in asp net
types of interface in c#
interview questions on inheritance in c# for experienced
user interface in c#
abstract class in c#

ASP.NET Interview questions Data security

ASP.NET Interview questions Data security

What are the best practices to follow to secure connection strings in an ASP.NET web application?1. Always store connection strings in the site's Web.config file. Web.config is very secure. Users will not be able to access web.config from the browser.
2. Do not store connection strings as plain text. To help keep the connection to your database server secure, it is recommended that you encrypt connection string information in the configuration file.
3. Never store connection strings in an aspx page.
4. Never set connection strings as declarative properties of the SqlDataSource control or other data source controls.

Why is "Connecting to SQL Server using Integrated Security" considered a best practice?
Connecting to SQL Server using integrated security instead of using an explicit user name and password, helps avoid the possibility of the connection string being compromised and your user ID and password being exposed.
What is the advantage of storing an XML file in the applications App_Data folder? 
The contents of the App_Data folder will not be returned in response to direct HTTP requests.
What is Script injection?
A script injection attack attempts to send executable script to your application with the intent of having other users run it. A typical script injection attack sends script to a page that stores the script in a database, so that another user who views the data inadvertently runs the code.

What is SQL injection?
A SQL injection attack attempts to compromise your database by creating SQL commands that are executed instead of, or in addition to, the commands that you have built into your application.

What are the best practices to keep in mind when accepting user input on a web application?
1. Always use validation controls whenever possible to limit user input to acceptable values.
2. Always check the IsValid property of the aspx page. Run the server side code only if the IsValid property value is true. A value of false means that one or more validation controls have failed a validation check.
3. Always perform server side validation irrespective of client side validation being performed or not. This will protect your web application even if the client has by passed the client side validation by disabling javascript in the web browser.
4. Also make sure to re validate user input in the business logic layer of your application.
What are the steps to follow to avoid Script Injection attacks?
1. Encode user input with the HtmlEncode method. This method turns HTML into its text representation.
2. If you are using the GridView control with bound fields, set the BoundField object's HtmlEncode property to true. This causes the GridView control to encode user input when the row is in edit mode.

What are the steps to follow to avoid SQL Injection attacks?
Always use parameterized queries or stored procedures instead of creating SQL commands by concatenating strings together.

Can you encrypt view state data of an aspx page?
Yes, you encrypt view state data of an aspx page by setting the page's ViewStateEncryptionMode property to true.

Keywords:
asp.net mvc interview questions
asp.net mvc security interview questions
net interview questions for 6 years experience
c# interview questions
senior net developer interview questions and answers
web security interview questions
net telephonic interview questions
how to explain asp net mvc project in interview
script injection example
cross site scripting
code injection example
sql injection
cross site scripting tutorial
html injection
how to prevent script injection in java
client side json injection hackerone
sql injection types
how to prevent sql injection
sql injection code list
sql injection 1=1
sql injection php
sql injection test
sql injection owasp
sql injection password