Quantcast
Tuesday 7 december 2010 2 07 /12 /Dec /2010 14:21

ASP.NET Interview questions Caching , Application and ASP.NET page life cycle - Part 1 ( 5 Questions ).

Below are Most  important ASP.NET interview questions from caching aspect during .NET Interviews .
Day before yesterday I was at Mumbai Seepz giving a C# interview and below are some questions which where asked from ASP.NET aspect.
What are the various ways of doing caching in ASP.NET ?
You can cache by using output cache directive , cache object and application object.
The next thing the interviewer asked was regarding cache and application object.
What's the difference between cache and application object ?
In cache object you can define dependency properties , in application object you can not. In other words when the data
which is cached changes even the cache object gets refreshed , but this is not the case of application object. You need to do a pull to refresh the data.
This is a 100% sure question , how does ASP.NET page life cycle work ?.
What are the different events which occur in ASP.NET page life cycle ?
Init , load , validate , event and render.
Remember SILVER ( Init , load , validate , event  and render).
What are HttpHandlers and HttpModules ?
Both of these entities have one common goal , i.e. intercepting ASP.NET request and performing some operation on the request before it reaches the main object.
But they way they intercept the request are different. HttpHandler intercepts the request using file extensions while HttpModule intercepts the request using Http events.
You can refer ASP.NET page life cycle article here for details.
Why do we need session variables ?
Http is a stateless protocol , after every request and response it forgets its original state. Session variables helps us to remember the state after every request and response.
Well frankly I did not clear this ASP.NET  interview as I failed to answer simple .NET interview questions. So i will suggest every one to go through .NET Interview questions  from this link. This article is part 1 of ASP.NET interview question and answers i will be soon posting by other questions in the coming week... Happy job hunting.
By Shivprasad koirala

ASP
By Shivprasad koirala
Enter comment - View the 0 comments
Monday 6 december 2010 1 06 /12 /Dec /2010 13:44

Most important ASP.NET Interview questions

Below are Most  important ASP.NET interview questions which repeat again and again in .NET Interviews .

Most important ASP.NET Interview questions and answers

What’ is the sequence in which ASP.NET events are processed?

In which event are the controls fully loaded?

How can we identify that the Page is Post Back?

How does ASP.NET maintain state in between subsequent request?

What is event bubbling? How do we assign page specific attributes?

How do we ensure viewstate is not tampered?

What is the use of @ Register directives?

What is the use of Smart Navigation property?

What is AppSetting Section in “Web.Config” file?

Where is View State information stored?

what is the use of @ Output Cache directive in ASP.NET.

How can we create custom controls in ASP.NET?

How many types of validation controls are provided by ASP.NET?

Can you explain “AutoPostBack”?

How can you enable automatic paging in Data Grid?

What is the use of “GLOBAL.ASAX” file?

What is the difference between “Web.config” and “Machine.Config”?

What is a SESSION and APPLICATION object?

What is the difference between ‘Server.Transfer’ and ‘response. Redirect’ ?

What is the difference between Authentication and authorization?

what is impersonation in ASP.NET?

Can you explain in brief how the ASP.NET authentication process works?

What are the various ways of authentication techniques in ASP.NET?

How does authorization work in ASP.NET?

What is difference between Data grid, Datalist, and repeater?

From performance point of view, how do they rate?

What is the method to customize columns in Data Grid?

How can we format data inside Data Grid?

How to decide on the design consideration to take a Data grid, data list, or repeater?

Difference between ASP and ASP.NET?

What are major events in GLOBAL.ASAX file?

What order they are triggered?

Do session use cookies?

How can we force all the validation control to run?

How can we check if all the validation control are valid and proper?

If client side validation is enabled in your Web page, does that mean server side code is not run.

Which JavaScript file is referenced for validating the validators at the client side?

How to disable client side script in validators?

How can I show the entire validation error message in a message box on the client side?

You find that one of your validations is very complicated and does not fit in any of the validators, what will you do?

What exactly happens when ASPX page is requested from a browser?

How can we kill a user session?

How do you upload a file in ASP.NET?

How do I send email message from ASP.NET?

What are different IIS isolation levels?

ASP used STA threading model, what is the threading model used for ASP.NET.

What is the use of <%@ page aspcompat=true %> attribute?

B) Explain the differences between Server-side and Client-side code?

Can you explain Forms authentication in detail?

How do I sign out in forms authentication?

If cookies are not enabled at browser end does form Authentication work?

How to use a checkbox in a data grid?

What are the steps to create a windows service in VB.NET?

What is the difference between “Web farms” and “Web garden”?

How do we configure “Web Garden”?

What is the main difference between Grid layout and Flow Layout?

What’s the difference between trace and debug in ASP.NET?

How do you enable tracing in on an ASP.NET page?

Which namespace is needed to implement debug and trace ?

Can you explain the concept of trace listener?

What are trace switches?

By Shivprasad koirala
Enter comment - View the 0 comments
Sunday 5 december 2010 7 05 /12 /Dec /2010 07:49

Top 10 Interview Questions on OOPS

 

.Net  Interview Questions and Answers on OOPS

 

1.       What is an Object in OOPS?

An object is a software bundle of variables and related methods. Objects are related to real life scenario. Class is the general thing and object is the specialization of general thingObjects is instance of classes.

 

 Declaration of an Object in OOPs

ClassName objectName=new ClassName();

E.g.: Person objPerson= new Person();

 

An object is characterized by concepts like:

•            Attribute

•             Behavior

•             Identity

 

 

2.            What is an Attribute in OOPs?

•        Attributes define the characteristics of a class.

•        The set of values of an attribute of a particular object is called its state.

•        In Class Program attribute can be a string or it can be a integer

 

 

 

 

3.            What is a Behavior in OOPS?

•        Every object has behavior

•        In C#, behaviors of objects are written in methods.

•        If a behavior of an object needs to be performed, then the corresponding method is called.

 

 

4.            What is an Identity in OOPS?

•        Each time an object is created the object identity is been defined.

•        This identity is usually created using an identifier which is derived from the type of item

 

5.           What is Encapsulation in OOPS?

•        Encapsulation is one of the fundamental principles of object-oriented programming.

•        Encapsulation is a process of hiding all the internal details of an object from the outside world

•        Encapsulation is the ability to hide its data and methods from outside the world and only expose data and methods that are required

•        Encapsulation is a protective barrier that prevents the code and data being randomly accessed by other code or by outside the class

•        Encapsulation gives us maintainability, flexibility and extensibility to our code.

•        Encapsulation makes implementation inaccessible to other parts of the program and protect from whatever actions might be taken outside the function or class.

•        Encapsulation provides a way to protect data from accidental corruption

•        Encapsulation hides information within an object

•        Encapsulation is the technique or process of making the fields in a class private and providing access to the fields using public methods

•        Encapsulation gives you the ability to validate the values before the object user change or obtain the value

•        Encapsulation allows us to create a "black box" and protects an objects internal state from corruption by its clients.

 

 

 

 

There are two ways to create a validation process.

1.            Using Assessors and Mutators

2.            Using properties

 

Benefits of Encapsulation

•        In Encapsulation fields of a class can be read-only or can be write-only

•        A class can have control over in its fields

•        A class can change data type of its fields anytime but users of this class do not need to change any code

 

 

6.  What is Inheritance in OOPS?

•                    Inheritance, together with encapsulation and polymorphism, is one of the three primary characteristics (concept) of object-oriented programming

•                    Inheritance enables you to create new classes that reuse, extend, and modify the behavior that is defined in other classes

•                    The Class whose methods and variables are defined is called super class or base class

•                    The Class that inherits methods and variables are defined is called sub class or derived class

•                    Sometimes base class known as generalized class and derived class known as specialized class

•                    Keyword to declare inheritance is “:” (colon) in visual c#

 

Benefits of using Inheritance 

•                    Once a behavior (method) or property is defined in a super class(base class),that behavior  or property is automatically inherited by all subclasses (derived class).

•                    Code reusability increased through inheritance

•                    Inheritance provide a clear model structure which is easy to understand without much complexity

•                    Using inheritance, classes become grouped together in a hierarchical tree structure

•                    Code are easy to manage and divided into parent and child classes

 

 

 

7. What is Polymorphism in OOPS?

 

•                    Polymorphism is one of the primary characteristics (concept) of object-oriented programming

•                    Poly means many and morph means form. Thus, polymorphism refers to being able to use many forms of a type without regard to the details

•                    Polymorphism is the characteristic of being able to assign a different meaning specifically, to allow an entity such as a variable, a function, or an object to have more than one form

•                    Polymorphism is the ability to process objects differently depending on their data types

•                    Polymorphism is the ability to redefine methods for derived classes.

 

Types of Polymorphism

•                    Compile time Polymorphism

•                    Run time Polymorphism

 

 

8. What is Compile Time Polymorphism in OOPS?

•                    Compile time Polymorphism also known as method overloading

•                    Method overloading means having two or more methods with the same name but with different signatures

 

 

 

9. What is Run Time Polymorphism in OOPS?

•                    Run time Polymorphism also known as method overriding

•                    Method overriding means having two or more methods with the same name , same signature but with different implementation

 

 

 

 

 

10. What is Access Modifier in OOPS?

Access modifiers determine the extent to which a variable or method can be accessed from another class or object

 

The following five accessibility levels can be specified using the access modifiers

•                            Private

•                            Protected

•                            Internal

•                            Protected internal

•                            Public

 

By Shivprasad koirala
Enter comment - View the 0 comments
Saturday 4 december 2010 6 04 /12 /Dec /2010 14:49

7 simple steps to enable HTTPS on WCF WsHttp bindings

 

Get Interview tutorials and videos on .NET 3.5, 4.0, HTTPS,WCF,Bindings, SQL Server, CAS, Security, WCF, SharePoint, Azure, OOPS and many more on www.questpond.com


Introduction and Goal

Step 1:- Create a simple service using WCF project

Step 2 :- Enable transport level security in the web.config file of the service

Step 3:- Tie up the binding and specify HTTPS configuration

Step 4:- Make the web application HTTPS enabled

Step 5:- Consume the service in a web application

Step 6:- Suppress the HTTPS errors

Step 7:- Enjoy success

Source code



Introduction and Goal

When we talk about WCF security there are two ways one is the transport level security and the other is message level security. Transport level security is nothing but built in security by protocols itself. In message level security we need to encrypt the data, in other words security is injected in the data itself.
In this article we will look in to how we can implement transport level security using WsHttp bindings. We do not need to do extra development for transport level security because it’s more of the protocols inherent security model. In this article we will implement WsHttp using HTTPS as transport security.

 

Step 1:- Create a simple service using WCF project


The first step is to create a simple WCF project. So click on new project and select WCF service project. By default WCF project creates a default function ‘GetData()’. We will be using the same function for this sample.

public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
}


Step 2 :- Enable transport level security in the web.config file of the service

Next step is to enable transport security in WsHttp binding. This is done using the ‘Security’ XML tag as shown in the below code snippet.

<bindings>

<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>

</bindings>


Step 3:- Tie up the binding and specify HTTPS configuration

We need now tie up the bindings with the end points. So use the ‘bindingConfiguration’ tag to specify the binding name. We also need to specify the address where the service is hosted. Please note the HTTS in the address tag.

Change ‘mexHttpBinding’ to ‘mexHttpsBinding’ in the second end point.

<service name="WCFWSHttps.Service1" behaviorConfiguration="WCFWSHttps.Service1Behavior">

<!-- Service Endpoints -->
<endpoint address="https://localhost/WCFWSHttps/Service1.svc" binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="WCFWSHttps.IService1"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>

</service>

In the ‘serviceMetadata’ we also need to change ‘httpGetEnabled’ to ‘httpsGetEnabled’.

<serviceBehaviors>
........
.........
<serviceMetadata httpsGetEnabled="true"/>
.........
.........
</serviceBehaviors>


Step 4:- Make the web application HTTPS enabled

Now that we are done with the WCF service project creation and the necessary configuration changes are done. It’s time to compile the WCF service project and host the same in IIS application with HTTPS enabled.

We will be using ‘makecert.exe’ which is a free tool given by Microsoft to enable HTTPS for testing purpose. MakeCert (Makecert.exe) is a command-line tool that creates an X.509 certificate that is signed by a system test root key or by another specified key. The certificate binds a certificate name to the public part of the key pair. The certificate is saved to a file, a system certificate store, or both.

You can get the same from “C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin” or you can also get it from windows SDK.

You can type the below thing through your dos prompt on “C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin”. Please note “compaq-jzp37md0” is the server name so you need to replace with your PC name.

makecert -r -pe -n "CN= compaq-jzp37md0 " -b 01/01/2000 -e 01/01/2050 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12
 

If you run the same through your command prompt you should get a succeeded message as shown below.




Now it’s time to assign this certificate to your IIS website. So go to IIS properties , click on directory security tab and you should see server certificate tab.



So click on the server certificate tab and you will then be walked through an IIS certificate wizard. Click ‘Assign a existing certificate’ from the wizard.



You can see a list of certificates. The “compaq-jzp37md0” certificate is the one which we just created using ‘makecert.exe’.



Now try to test the site without ‘https’ and you will get an error as shown below….That means your certificate is working.




Do not forget to enable IIS anonymous access.

Step 5:- Consume the service in a web application

It’s time to consume the service application in ASP.NET web. So click on add service reference and specify your service URL. You will shown a warning box as shown in the below figure. When we used makecert.exe we did not specify the host name as the service URL. So just let it go.


Step 6:- Suppress the HTTPS errors

‘makecert.exe’ creates test certificates. In other words it’s not signed by CA. So we need to suppress those errors in our ASP.NET client consumer. So we have created a function called as ‘IgnoreCertificateErrorHandler’ which return true even if there are errors. This function is attached as a callback to ‘ServicePointManager.ServerCertificateValidationCallback’.

In the same code you can also see service consuming code which calls the ‘GetData’ function.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplicationConsumer.ServiceReference1;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

namespace WebApplicationConsumer
{
public partial class _Default : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler); 
Service1Client obj = new Service1Client();
Response.Write(obj.GetData(12));
}
public static bool IgnoreCertificateErrorHandler(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}
}
}

Step 7:- Enjoy success

Now to the easiest step, compile you ASP.NET client and enjoy success.

Source code

We have also attached source code which has both the client and service,click
http://www.codeproject.com/KB/WCF/7stepsWCF/WsHttpCertificates.zip

By Shivprasad koirala
Enter comment - View the 0 comments
Saturday 4 december 2010 6 04 /12 /Dec /2010 14:37

 

 

6 Steps to Enable Transactions in WCF

Get Interview tutorials and videos on .NET 3.5, 4.0, WCF,ASP.NET, SQL Server, CAS, Security, WCF, SharePoint, Azure, OOPS and many more on www.questpond.com

Download the source code from here http://www.codeproject.com/KB/WCF/WCFTransactions/WCFTransactions.zip

Table of Contents

Introduction and Goal

In this article, we will try to understand how we can implement transactions in WCF service. So we will create two WCF services which do database transactions and then unite them in one transaction. We will first understand the 6 important steps to enable transactions in WCF services. At the end of the article, we will try to force an error and see how the transaction is rolled back after the error.

Step 1: Create Two WCF Services

The first step is to create two WCF service projects which will participate in one transaction. In both of these WCF services, we will do database transactions and we will try to understand how a WCF transaction unifies them. We have also created a web application with name WCFTransactions which will consume both the services in one transaction scope.




Step 2: Attribute Interface Methods with TransactionFlow

In both the WCF services, we will create a method called UpdateData which will insert into the database. So the first thing is to create the interface class with ServiceContract attribute and the method UpdateData with OperationContract attribute. In order to enable transaction in UpdateData method, we need to attribute it with TransactionFlow and we have specified that transactions are allowed for this method using TransactionFlowOption.Allowed enum.

[ServiceContract]
public interface IService1
{
[OperationContract]
[TransactionFlow(TransactionFlowOption.Allowed)]
void UpdateData();
}


Step 3: Attribute the Implementation with TransactionScopeRequired

The 3rd step is to attribute the implementation of the WCF services with TransactionScopeRequired as true. Below is the code snippet which has a simple database inserting function, i.e. UpdateData which is attributed by TransactionScopeRequired attribute.

[OperationBehavior(TransactionScopeRequired = true)]
public void UpdateData()
{
SqlConnection objConnection = new SqlConnection(strConnection);
objConnection.Open();
SqlCommand objCommand = new SqlCommand("insert into Customer
        (CustomerName,CustomerCode) values('sss','sss')",objConnection);
objCommand.ExecuteNonQuery();
objConnection.Close();
}

Step 4: Enable Transaction Flow using WCF Service Config File

We also need to enable transactions for wsHttpBinding by setting the transactionFlow attribute to true.

<bindings>
<wsHttpBinding>
<binding name="TransactionalBind" transactionFlow="true"/>
</wsHttpBinding>
</bindings>

The transaction enabled binding we need to attach with the end point through which our WCF service is exposed.

<endpoint address="" binding="wsHttpBinding" 
        bindingConfiguration="TransactionalBind" contract="WcfService1.IService1">

Step 5: Call the 2 Services in One Transaction

Now that we are done with enabling our server side transaction, it’s time to call the above 2 services in 1 transaction. We need to use the TransactionScope object to group the above 2 WCF services in one transaction. To commit all the WCF transactions, we call the Complete method of the Transactionscope object. To rollback, we need to call the Dispose method.

using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew))
{
try
{

// Call your webservice transactions here
ts.Complete();
}
catch (Exception ex)
{
ts.Dispose();
}
}

Below is the complete code snippet in which we have grouped both the WCF transactions in one scope as shown below:

using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew))
{
try
{
ServiceReference1.Service1Client obj = new ServiceReference1.Service1Client();
obj.UpdateData();
ServiceReference2.Service1Client obj1 = new ServiceReference2.Service1Client();
obj1.UpdateData();
ts.Complete();
}
catch (Exception ex)
{
ts.Dispose();
}
}

Step 6: Test If Your Transaction Works

It’s time to test if the transactions really work. We are calling two services, both of which are doing an insert. After the first WCF service call, we are forcing an exception. In other words, the data insert of the first WCF service should revert back. If you check the database records, you will see no records are inserted by the WCF service.


Click to enlarge

History

  • 6th August, 2009: Initial post
By Shivprasad koirala
Enter comment - View the 0 comments

Important .NET and C# interview questions and answers

.Net interview questions: - Explain why it is not preferred to use finalize for clean up?

.Net interview questions: - Show the five levels in CMMI?

.NET interview questions and answers: – Which is the best place to store connection string in .NET projects?

C# interview questions and answers: – Explain the use of Icomparable in c#?

C# interview questions: - How can we check which rows have changed since dataset was loaded?

C# interview questions and answers: - Can you write a simple c# code to display Fibonacci series?

.NET interview questions and answers: - What is difference betweenIcomparable VS Icomparer ?

C# and .NET interview question: -What is short circuiting in C#?

C# and .NET interview question: - What are symmetric and asymmetric algorithms?

Important c# and .NET interview question on object pooling and Gridview events?

.NETinterview questions and answers: – Will the finally run in this code?

How to prepare for c# and .NETinterviews?

C# and .NET Interview questions: - What is Thread.Join () in threading?

.NET Interview questions and answers: -What is serialization and deserialization in .NET?

C# and .NET interview question: - What is hashing?

c# and .NET interview question:- what connects dataset and data source ?

.Net interview questions and answers: - What is the difference between “Web.config” and “Machine.Config”?

.NET interview questions and answers: - What is TPL?

.NET Interview questions and answers: -What are different access modifiers?

.NET and c# Interview Question and answers: – If we want to update interface with new methods, what is the best practice?

 MVC ( Model view controller) interview questions and answers      

ASP.NET Application and Page Life Cycle 

12 Important FAQ’s on VSTS Testing (Unit testing, load testing, automated testing, database testing and code coverage) 

 6 important use of Partial/Mock testing

6 important uses of Delegates and Events

7 Simple Steps to Run Your First Azure Blob Program

8 Steps to Create Workflows using SharePoint Designer

Azure FAQ Part 1

C# Code Reviews using StyleCop – Detailed Article

Four real world uses of Partial classes and Partial methods

SharePoint Quick Start FAQ Part 1

SharePoint Quick Start FAQ Part 6 – Workflows, Workflows and Workflows

SharePoint Workflow Basics

 

 

 

 

. NET and C# interview questions videos

MVC Interview questions videos

Viewdata,viewbag,tempdata

 

 

MVC Interview questions and answers Article

 

(Model view controller)MVC Interview questions and answers

MVC interview questions with answers video: – What is Web API how to implement the same?

 

 

WCF Interview questions videos

 

overloading in WCF

WCF fault exceptions ?

 

C# Interview Questions & Answers Article

 

12 Important FAQ’s on VSTS Testing (Unit testing, load testing, automated testing, database testing and code coverage)

6 important use of Partial/Mock testing

6 important uses of Delegates and Events

7 Simple Steps to Run Your First Azure Blob Program

8 Steps to Create Workflows using SharePoint Designer

Azure FAQ Part 1

C# Code Reviews using StyleCop – Detailed Article

Four real world uses of Partial classes and Partial methods

SharePoint Quick Start FAQ Part 1

SharePoint Quick Start FAQ Part 6 – Workflows, Workflows and Workflows

SharePoint Workflow Basics

C# (Csharp) interview questions and answers: – What are indexers in .NET?

C# OOP interview questions and answers: - I do not want to implement all the interface methods?

C# design pattern (UNIT of Work Design Pattern)

C# design pattern interview questions – What is Dependency injection ?

C# interview questions and answers: - What is the difference between “==” and .Equals()?

How questions are asked in c# interviews?

C# design pattern interview question: - DI vs IOC

8 important C# Interview questions on IL code, JIT, CLR, CTS, CLS and CAS

What is the difference between Reflection and Dynamic in C#?

Algorithm Interview Questions

Algorithm interview questions and answers: – Can you write code for bubble sort algorithm?

Algorithm interview questions and answers: – What is inserted sort algorithm?

ASP.NET Interview Questions & Answers Article







 

SQL Server Interview Questions & Answers Article

 

SQL Server Interview Questions & Answers Article

SQL Server interview questions and answers: - What is HID data type in SQL Server ?

 

.NET INTERVIEW QUESTIONS & ANSWERS ARTICLE

 

.NET interview questions and answers: - How to reverse a string in .NET ( DotNet)?

.NET interview questions and answers: - What is the use of Click Once?

.NET interview questions and answers: - Will the below codes create new instances?

C# and .NET interview questions with answers – What is Nuget?

Dependency injection (DI) VS Inversion of Control (IOC)

.NET interview questions with answers: - What is the difference between Reflection and Dynamic?


WPF INTERVIEW QUESTIONS & ANSWERS ARTICLE

 

6 important WPF and Silverlight Multi-threading interview questions with answers


Create your blog for free on over-blog.com - Contact - Terms of Service - Earn Royalties - Report abuse - Most commented articles