Tuesday, February 19, 2008

Modify web.config

http://www.beansoftware.com/ASP.NET-Tutorials/Modify-Web.Config-Run-Time.aspx

Wednesday, February 6, 2008

Dotnet interview questions

References : http://interviewhelper.blogspot.com/2007/08/net-interview-questions.html


.NET Interview Questions

What is garbage collection?
Can we force garbage collector to run ?
What is reflection?
What are different type of JIT ?
What are Value types and Reference types ?
What is concept of Boxing and Unboxing ?
What’s difference between VB.NET and C# ?
What’s difference between System exceptions and Application exceptions?
What is CODE Access security?
What is a satellite assembly?
How to prevent my .NET DLL to be decompiled?
What’s the difference between Convert.toString and .toString() method ?
What is Native Image Generator (Ngen.exe)?
We have two version of the same assembly in GAC? I want my client to make choice of
which assembly to choose?
What is CodeDom?

.NET Interoperability
How can we use COM Components in .NET?
Twist : What is RCW ?
Once i have developed the COM wrapper do i have to still register the COM in registry?
How can we use .NET components in COM?
Twist :- What is CCW (COM callable wrapper) ?, What caution needs to be taken in order
that .NET components is compatible with COM ?
How can we make Windows API calls in .NET?
When we use windows API in .NET is it managed or unmanaged code ?
What is COM ?
What is Reference counting in COM ?
Can you describe IUKNOWN interface in short ?
Can you explain what is DCOM ?
How do we create DCOM object in VB6?
How to implement DTC in .NET ?
How many types of Transactions are there in COM + .NET ?
How do you do object pooling in .NET ?
What are types of compatibility in VB6?
What is equivalent for regsvr32 exe in .NET ?

Threading
What is Multi-tasking ?
What is Multi-threading ?
What is a Thread ?
Did VB6 support multi-threading ?
Can we have multiple threads in one App domain ?
Which namespace has threading ?
Can you explain in brief how can we implement threading ?
How can we change priority and what the levels of priority are provided by .NET ?
What does Addressof operator do in background ?
How can you reference current thread of the method ?
What's Thread.Sleep() in threading ?
How can we make a thread sleep for infinite period ?
What is Suspend and Resume in Threading ?
What the way to stop a long running thread ?
How do i debug thread ?
What's Thread.Join() in threading ?
What are Daemon thread's and how can a thread be created as Daemon?
When working with shared data in threading how do you implement synchronization ?
Can we use events with threading ?
How can we know a state of a thread?
What is a monitor object?
What are wait handles ?
Twist :- What is a mutex object ?
what is ManualResetEvent and AutoResetEvent ?
What is ReaderWriter Locks ?
How can you avoid deadlock in threading ?
What’s difference between thread and process?

Interview questions

References : http://interviewhelper.blogspot.com/2007/08/net-interview-questions.html
Caching Concepts
What is application object ?
What’s the difference between Cache object and application object ?
How can get access to cache object ?
What are dependencies in cache and types of dependencies ?
Can you show a simple code showing file dependency in cache ?
What is Cache Callback in Cache ?
What is scavenging ?
What are different types of caching using cache object of ASP.NET?
How can you cache different version of same page using ASP.NET cache object ?
How will implement Page Fragment Caching ?
What are ASP.NET session and compare ASP.NET session with classic ASP session
variables?
Which various modes of storing ASP.NET session ?
Is Session_End event supported in all session modes ?
What are the precautions you will take in order that StateServer Mode work properly ?
What are the precautions you will take in order that SQLSERVER Mode work properly ?
Where do you specify session state mode in ASP.NET ?
What are the other ways you can maintain state ?
What are benefits and Limitation of using Hidden fields ?
What is ViewState ?
Do performance vary for viewstate according to User controls ?
What are benefits and Limitation of using Viewstate for state management?
How an you use Hidden frames to cache client data ?
What are benefits and Limitation of using Hidden frames?
What are benefits and Limitation of using Cookies?
What is Query String and What are benefits and Limitation of using Query Strings?

OOPS
What is Object Oriented Programming ?
What’s a Class ?
What’s a Object ?
What’s the relation between Classes and Objects ?
What are different properties provided by Object-oriented systems ?
Twist :- Can you explain different properties of Object Oriented Systems?
Twist :- What’s difference between Association , Aggregation and Inheritance relationships?
How can we acheive inheritance in VB.NET ?
What are abstract classes ?
What’s a Interface ?
What is difference between abstract classes and interfaces?
What is a delegate ?
What are event’s ?
Do events have return type ?
Can event’s have access modifiers ?
Can we have shared events ?
What is shadowing ?
What’s difference between Shadowing and Overriding ?
What’s difference between delegate and events?
If we inherit a class do the private variables also get inherited ?
What are different accessibility levels defined in .NET ?
Can you prevent a class from overriding ?
What’s the use of “MustInherit” keyword in VB.NET ?
Why can not you specify accessibility modifier in Interface ?
What are similarities between Class and structure ?
What’s the difference between Class and structure’s ?
What does virtual keyword mean ?
What are shared (VB.NET)/Static(C#) variables?
What is Dispose method in .NET ?
Whats the use of “OverRides” and “Overridable” keywords ?
Where are all .NET Collection classes located ?
What is ArrayList ?
What’s a HashTable ?
Twist :- What’s difference between HashTable and ArrayList ?
What are queues and stacks ?
What is ENUM ?
What is nested Classes ?
What’s Operator Overloading in .NET?
In below sample code if we create a object of class2 which constructor will fire first ?
What’s the significance of Finalize method in .NET?
Why is it preferred to not use finalize for clean up?
How can we suppress a finalize method?
What’s the use of DISPOSE method?
How do I force the Dispose method to be called automatically, as clients can forget to call
Dispose method?
In what instances you will declare a constructor to be private?
Can we have different access modifiers on get/set methods of a property ?
If we write a goto or a return statement in try and catch block will the finally block
execute ?
What is Indexer ?
Can we have static indexer in C# ?
In a program there are multiple catch blocks so can it happen that two catch blocks are
executed ?
What is the difference between System.String and System.StringBuilder classes?

ASP.NET
What’s 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 PostBack ?
How does ASP.NET maintain state in between subsequent request ?
What is event bubbling ?
How do we assign page specific attributes ?
Administrator wants to make a security check that no one has tampered with ViewState
, how can he ensure this ? 153
What’s the use of @ Register directives ?
What’s the use of SmartNavigation property ?
What is AppSetting Section in “Web.Config” file ?
Where is ViewState information stored ?
What’s the use of @ OutputCache 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 what is “AutoPostBack” feature in ASP.NET ?
How can you enable automatic paging in DataGrid ?
What’s the use of “GLOBAL.ASAX” file ?
What’s the difference between “Web.config” and “Machine.Config” ?
What’s a SESSION and APPLICATION object ?
What’s difference between Server.Transfer and response.Redirect ?
What’s 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’s difference between Datagrid , Datalist and repeater ?
From performance point of view how do they rate ?
What’s the method to customize columns in DataGrid?
How can we format data inside DataGrid?
How will decide the design consideration to take a Datagrid , datalist 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 you have 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?
I want to show the entire validation error message in a message box on the client side?
You find that one of your validation is very complicated and does not fit in any of the
validators , so what will you do ?
What is Tracing in ASP.NET ?
How do we enable tracing ?
What exactly happens when ASPX page is requested from 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 , whats the threading model used for ASP.NET ?
Whats the use of <%@ page aspcompat=true %> attribute ?
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 datagrid?
What are the steps to create a windows service in VB.NET ?
What’s the difference between “Web farms” and “Web garden”?
How do we configure “WebGarden”?
What is the main difference between Gridlayout and FlowLayout ?

.NET Architecture
What are design patterns ?
What’s difference between Factory and Abstract Factory Pattern’s?
What’s MVC pattern?
Twist: - How can you implement MVC pattern in ASP.NET?
How can we implement singleton pattern in .NET?
How do you implement prototype pattern in .NET?
Twist: - How to implement cloning in .NET ? , What is shallow copy and deep copy ?
What are the situations you will use a Web Service and Remoting in projects?
Can you give a practical implementation of FAƇADE patterns?
How can we implement observer pattern in .NET?
What is three tier architecture?
Have you ever worked with Microsoft Application Blocks, if yes then which?
What is Service Oriented architecture?
What are different ways you can pass data between tiers?
What is Windows DNA architecture?
What is aspect oriented programming?

Links for design patterns

1. Links for design patterns :

http://www.dofactory.com/Patterns/Patterns.aspx#list


2. Caching Links :

Implementing caching
http://www.ondotnet.com/pub/a/dotnet/2002/12/30/cachingaspnet.html


http://www.c-sharpcorner.com/UploadFile/vishnuprasad2005/ImplementingC

achinginASP.NET11302005072210AM/ImplementingCachinginASP.NET.aspx?Arti

cleID=d468ed8b-bd04-42ca-bb55-080955042c5f


http://msdn2.microsoft.com/en-us/library/ms978499.aspx

http://msdn2.microsoft.com/en-us/library/ms978500.aspx

http://msdn2.microsoft.com/en-us/library/ms978503.aspx

http://driveindotnet.blogspot.com/2007/12/basic-features-of-oops-conce

pt-are.html

Thursday, January 31, 2008

Something about constructors

What is a constructor? Explain the New Keyword. What is a Private Constructor?
Constructor - A constructor is a function with the same name as that of the class. The Default Constructor of a class is without an argument. The default constructor ensures that every member data is initialized to a default value. Constructors provide a way for classes to initialize a state for their members. Note that constructors dont have a return type(not even void).
public SomeClass(){Console.Writeline("Vishal says, Default Constructor is called");}\public SomeClass(string str){Console.Writeline("Vishal says, Custom Constructor is called" + str);}
When a custom constructor is defined, the Default Constructor is not called. A constructor may also be overloaded.
New - This keyword may be used as a modifier and as an operator. When used as an operator, it creates an object on a heap to invoke constructors. When used an a modifier, it hides an inherited member from the base class member.
As an operator, it can be used to create an object and then to invoke the constructor of the class. See example below.
ExampleSomeClass objSomeClass = new SomeClass(); //Creating a class object and invoking its constructor
float amount = new float(); //Creating an object of the type, and invoking its constructor
As a modifier, it is used to explicitly hide a member from the base class. See example.
Examplepublic class MamaClass{public void SomeMethod() { ... }}
public class BabyClass : MamaClass{new public void SomeMethod() { .... }}
Private Constructor - When a constructor is created with a private specifier, it is not possible for other classes to derive from this class, neither is it possible to create an instance of this class. They are usually used in classes that contain static members only. It is also used to create Singleton classes.

Abstract clas Vs Interface

What is the difference between abstract class and interface?
If a class is to serve the purpose of providing common fields and members to all subclasses, we create an Abstract class. For creating an abstract class, we make use of the abstract keyword. Such a class cannot be instantiated. Syntax below:
abstract public class Vehicle { }
Above, an abstract class named Vehicle has been defined. We may use the fields, properties and member functions defined within this abstract class to create child classes like Car, Truck, Bike etc. that inherit the features defined within the abstract class. To prevent directly creating an instance of the class Vehicle, we make use of the abstract keyword. To use the definitions defined in the abstract class, the child class inherits from the abstract class, and then instances of the Child class may be easily created.Further, we may define abstract methods within an abstract class (analogous to C++ pure virtual functions) when we wish to define a method that does not have any default implementation. Its then in the hands of the descendant class to provide the details of the method. There may be any number of abstract methods in an abstract class. We define an abstract method using the abstract keyword. If we do not use the abstract keyword, and use the virtual keyword instead, we may provide an implementation of the method that can be used by the child class, but this is not an abstract method.Remember, abstract class can have an abstract method, that does not have any implementation, for which we use the abstract keyword, OR the abstract class may have a virtual method, that can have an implementation, and can be overriden in the child class as well, using the override keyword. Read example below
Example: Abstract Class with Abstract methodnamespace Automobiles{ public abstract class Vehicle { public abstract void Speed() //No Implementation here, only definition }}
Example: Abstract Class with Virtual methodnamespace Automobiles{ public abstract class Vehicle { public virtual void Speed() //Can have an implementation, that may be overriden in child class { ... } }
Public class Car : Vehicle{Public override void Speed() //Here, we override whatever implementation is there in the abstract class { ... //Child class implementation of the method Speed() }}}

An Interface is a collection of semantically related abstract members. An interface expresses through the members it defines, the behaviors that a class needs to support. An interface is defined using the keyword interface. The members defined in an interface contain only definition, no implementation. The members of an interface are all public by default, any other access specifier cannot be used. See code below:
Public interface IVehicle //As a convention, an interface is prefixed by letter I{ Boolean HasFourWheels()}

Time to discuss the Difference between Abstract Class and Interface
1) A class may inherit only one abstract class, but may implement multiple number of Interfaces. Say a class named Car needs to inherit some basic features of a vehicle, it may inherit from an Aabstract class named Vehicle. A car may be of any kind, it may be a vintage car, a sedan, a coupe, or a racing car. For these kind of requirements, say a car needs to have only two seats (means it is a coupe), then the class Car needs to implement a member field from an interface, that we make, say ICoupe.2) Members of an abstract class may have any access modifier, but members of an interface are public by default, and cant have any other access modifier.3) Abstract class methods may OR may not have an implementation, while methods in an Interface only have a definition, no implementation.


REFERENCES
http://www.dotnetuncle.com/Difference/4_abstract_class_interface.aspx

Sunday, January 27, 2008

Automatically connect to database

Code for enumerating Instances of SQL Server (ADO.NET)

The following console application retrieves information about all of the visible SQL Server instances and displays the information in the console window


using System.Data.Sql;

class Program
{
static void Main()
{
// Retrieve the enumerator instance and then the data.
SqlDataSourceEnumerator instance =
SqlDataSourceEnumerator.Instance;
System.Data.DataTable table = instance.GetDataSources();

// Display the contents of the table.
DisplayData(table);

Console.WriteLine("Press any key to continue.");
Console.ReadKey();
}

private static void DisplayData(System.Data.DataTable table)
{
foreach (System.Data.DataRow row in table.Rows)
{
foreach (System.Data.DataColumn col in table.Columns)
{
Console.WriteLine("{0} = {1}", col.ColumnName, row[col]);
}
Console.WriteLine("============================");
}
}
}

Multiple inhertence in .NET

1. Can you use multiple inheritance in .NET?
.NET supports only single inheritance. However the purpose is accomplished using multiple interfaces.

2. Why don’t we have multiple inheritance in .NET?

There are several reasons for this. In simple words, the efforts are more, benefits are less. Different languages have different implementation requirements of multiple inheritance. So in order to implement multiple inheritance, we need to study the implementation aspects of all the languages that are CLR compliant and then implement a common methodology of implementing it. This is too much of efforts. Moreover multiple interface inheritance very much covers the benefits that multiple inheritance has

Positive thinking Vs Negative thinking

This is one of the best and simple article that i have found in net.
Hope this article helps you always.

Positive thinking

Positive Thinking vs Negative Thinking

I want to dedicate this to my father who will turn 80 this year. He has been a
positive influence in my life and has helped my through adversity with his
positive attitude. He only had a eighth grade education but he rose to become a
regional vice president for a large retail corporation. I hope his words of wisdom
will help many of you.

From My Father



Are you the type of person who always thinks negative? Well let's change
the way you think right away. We must change the way you look at things, and add just a
few words in your vocabulary.



1. YES FOR NO

2. CAN FOR CANNOT

3. WILL FOR WILL NOT

4. ENCOURAGE FOR DISCOURAGE

5. LISTEN FOR TALKING

6. LOVE FOR HATE

7. TAKE A PROBLEM TURN IT INTO AN OPPORTUNITY

It seems that most negative thinking people think that everything is wrong,
it's the other persons fault, I can't get along with people, I have no friends,
I irritate people, I complain all the time, I can't get a promotion at work, my
boss doesn't like me. We can go on and on but nothing is going to change unless
you change it with a different outlook on the way that you think, and how you
present yourself to other people. Now reading about this you might think
whoever is writing this, is writing about me. This is true because all of us at
sometime or another lose focus on what we do and how we affect other people. It
really doesn't matter what kind of job that you have, or even if you are the
CEO, Manager of a baseball team, a team leader, you must be able to get along
with people. if you can't get along with people then you lose. You can't win
or put your point across because no one will respect you or anything that you say.
If you think that thinking positive is only for your work then you are wrong.
You must think positive at all times. Positive thinking turns people
on, negative thinking turns people off.





THINGS TO REMEMBER



1. NOTHING HAPPENS UNLESS YOU MAKE IT HAPPEN

2. BE A DOER NOT A WISHER

3. BE A LEADER NOT A FOLLOWER

4. LISTEN TO THE OTHER PERSON POINT OF VIEW

5 TAKE A PROBLEM TURN IT INTO AN OPPORTUNITY

6. BE OPEN MINDED

7. DON'T BE RIGID IN YOUR THINKING

8. THINK AND LISTEN BEFORE YOU TALK

9. LEARN AND PLAN AHEAD BECAUSE KNOWLEDGE IS POWER

References : http://www.resumewritersguide.com/resumepositive.htm
1. What are the new Navigation Controls in Asp.net 2.0?

The navigation controls provide common UI for navigating between pages in your site, such as treeview, menu, and sitemappath. These controls use the site navigation service in ASP.NET 2.0 to retrieve the custom structure you have defined for your site.

References: http://www.megasolutions.net/kb/Asp_Net_2_0_Interview_Questions.aspx

2. What are the new Login Controlsin Asp.net 2.0?

The new login controls provide the building blocks to add authentication and authorization-based UI to your site, such as login forms, create user forms, password retrieval, and custom UI for logged in users or roles. These controls use the built-in membership and role services in ASP.NET 2.0 to interact with the user and role information defined for your site.

References: http://www.megasolutions.net/kb/Asp_Net_2_0_Interview_Questions.aspx

3. Do I need IIS to run Web applications?

Ans:
If you are using Visual Studio, you can use the ASP.NET Development Server built into Visual Studio to test your pages. The server functions as a local Web server, running ASP.NET Web pages in a manner virtually identical to how they run in IIS. To deploy a Web application, you need to copy it to a computer running IIS version 5 or 6.

4. Can I hide the source code for my page?

Ans:
Server-side code is processed on the server and is not sent to the browser, so users cannot see it. However, client script is not protected; any client script that you add to your page, or that is injected into the page by server processing, is visible to users. If you are concerned about protecting your source code on the server, you can precompile your site and deploy the compiled version. For details, see Publishing Web Sites.


5. Do I have to use one programming language for all my Web pages?


No. Each page can be written in a different programming language if you want, even in the same application. If you are creating source code files and putting them in the \App_Code folder to be compiled at run time, all the code in must be in the same language. However, you can create subfolders in the \App_Code folder and use the subfolders to store components written in different programming languages.

General DotNet Faq's

1.Can Session state be shared between Classic ASP applications and ASP.NET applications?


References :


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/converttoaspnet.asp?

frame=true


2.Can I run ASP.NET on Apache?

Ans:Yes


3.Do I have to use a single programming language for all the Web pages in my app?

Ans: No. Each page can be written in a different programming
language if you want, even in the same application.

If you are creating source code files and putting them in the \App_Code folder
to be compiled at run time, all the code in must be in the same language.

However, you can create subfolders in the \App_Code folder and use subfolders
to store components written in different programming languages.

Ref : http://www.aspnetfaq.com/default.aspx?FaqId=265&CategoryId=39
///
4. # List the various stages of Page-Load lifecycle.

* Init()
* Load()
* PreRender()
* Unload()
Ref: http://www.megasolutions.net/kb/ASP_Net_InterView_Questions_1a.aspx

5. What is DLL Hell?

DLL hell is the problem that occurs when an installation of a newer application might break or

hinder other applications as newer DLLs are copied into the system and the older applications do

not support or are not compatible with them. .NET overcomes this problem by supporting multiple

versions of an assembly at any given time. This is also called side-by-side component versioning.

Ref: http://www.megasolutions.net/kb/ASP_Net_InterView_Questions_1a.aspx

6. Explain the differences between server-side and client-side code?

Server side scripting means that all the script will be executed by the server and interpreted as needed. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Since the code is included in the HTML page, anyone can see the code by viewing the page source. It also poses as a possible security hazard for the client computer.

Ref: http://www.megasolutions.net/kb/ASP_Net_InterView_Questions_1a.aspx

7. Different types of Directives.

* @ Page directive
* @ Import directive
* @ Implements directive
* @ Register directive
* @ Assembly directive
* @ OutputCache directive
* @ Reference directive

8. Describe the difference between inline and code behind.

Inline code is written along side the HTML in a page. There is no separate distinction between design code and logic code. Code-behind is code written in a separate file and referenced by the .aspx page.

9. What is the difference between Server.Transfer and Response.Redirect?

* Response.Redirect: This tells the browser that the requested page can be found at a new location. The browser then initiates another request to the new page loading its contents in the browser. This results in two requests by the browser.
* Server.Transfer: It transfers execution from the first page to the second page on the server. As far as the browser client is concerned, it made one request and the initial page is the one responding with content. The benefit of this approach is one less round trip to the server from the client browser. Also, any posted form variables and query string parameters are available to the second page as well.