Thursday 29 September 2011

DOTNET QUESTION AND ANSWER

CAS is the part of the .NET security model that determines whether or not a piece of code is allowed to run, and what resources it can use when it is running. For example, it is CAS that will prevent a .NET web applet from formatting your hard disk.
The CAS security policy revolves around two key concepts - code groups and permissions. Each .NET assembly is a member of a particular code group, and each code group is granted the permissions specified in a named permission set. For example, using the default security policy, a control downloaded from a web site belongs to the 'Zone - Internet' code group, which adheres to the permissions defined by the 'Internet' named permission set. (Naturally the 'Internet' named permission set represents a very restrictive range of permissions.)
   
Questions : 2 What are object pooling and connection pooling and difference? Where do we set the Min and Max Pool size for connection pooling?
Answers : 2
Object pooling is a COM+ service that enables you to reduce the overhead of creating each object from scratch. When an object is activated, it is pulled from the pool. When the object is deactivated, it is placed back into the pool to await the next request. You can configure object pooling by applying the ObjectPoolingAttribute attribute to a class that derives from the System.EnterpriseServices.ServicedComponent class. Object pooling lets you control the number of connections you use, as opposed to connection pooling, where you control the maximum number reached.
Following are important differences between object pooling and connection pooling:
1. Creation. When using connection pooling, creation is on the same thread, so if there is nothing in the pool, a connection is created on your behalf. With object pooling, the pool might decide to create a new object. However, if you have already reached your maximum, it instead gives you the next available object. This is crucial behavior when it takes a long time to create an object, but you do not use it for very long.
2. Enforcement of minimums and maximums. This is not done in connection pooling. The maximum value in object pooling is very important when trying to scale your application. You might need to multiplex thousands of requests to just a few objects. (TPC/C benchmarks rely on this.)

COM+ object pooling is identical to what is used in .NET Framework managed SQL Client connection pooling. For example, creation is on a different thread and minimums and maximums are enforced.
   
Questions : 3 What is a WebService and what is the underlying protocol used in it? Namespace?
Answers : 3
Web Services are applications delivered as a service on the Web. Web services allow for programmatic access of business logic over the Web. Web services typically rely on XML-based protocols, messages, and interface descriptions for communication and access. Web services are designed to be used by other programs or applications rather than directly by end user. Programs invoking a Web service are called clients. SOAP over HTTP is the most commonly used protocol for invoking Web services.
   
Questions : 4 What is serialization in .NET? What are the ways to control serialization?
Answers : 4
Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process of creating an object from a stream of bytes. Serialization/Deserialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database).Serialization can be defined as the process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, including the assembly containing the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created.
1. Binary serialization preserves type fidelity, which is useful for preserving the state of an object between different invocations of an application. For example, you can share an object between different applications by serializing it to the clipboard. You can serialize an object to a stream, disk, memory, over the network, and so forth. Remoting uses serialization to pass objects "by value" from one computer or application domain to another.
2. XML serialization serializes only public properties and fields and does not preserve type fidelity. This is useful when you want to provide or consume data without restricting the application that uses the data. Because XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is an open standard, which makes it an attractive choice.
   
Questions : 5 Explain SOAP, WSDL, UDDI in brief.Namespace?
Answers : 5
SOAP:-SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet, for example using request and reply messages or sending entire documents. SOAP is simple, easy to use, and completely neutral with respect to operating system, programming language, or distributed computing platform.After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise), a better way was needed to describe the messages and how they are exchanged.
WSDL :-The Web Services Description Language (WSDL) is a particular form of an XML Schema, developed by Microsoft and IBM for the purpose of defining the XML message, operation, and protocol mapping of a web service accessed using SOAP or other XML protocol. WSDL defines web services in terms of "endpoints" that operate on XML messages. The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly, so they can be mapped to multiple physical implementations. The current WSDL spec describes how to map messages and operations to SOAP 1.1, HTTP GET/POST, and MIME. WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages. The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using "ports").
UDDI :-The Universal Description, Discovery, and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information, including the web services a business exposes to the Internet. UDDI is an independent consortium of vendors, founded by Microsoft, IBM, and Ariba, for the purpose of developing an Internet standard for web service description registration and discovery. Microsoft, IBM, and Ariba also are hosting the initial deployment of a UDDI service, which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses). UDDI uses a private agreement profile of SOAP (i.e. UDDI doesn't use the SOAP serialization format because it's not well suited to passing complete XML documents (it's aimed at RPC style interactions). The main idea is that businesses use the SOAP APIs to register themselves with UDDI, and other businesses search UDDI when they want to discover a trading partner, for example someone from whom they wish to procure sheet metal, bolts, or transistors. The information in UDDI is categorized according to industry type and geographical location, allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact. Once a specific business is chosen, another call to UDDI is made to obtain the specific contact information for that business. The contact information includes a pointer to the target business's WSDL or other XML schema file describing the web service that the target business publishes. .
   
Questions : 6 What is Method Overriding? How to override a function in C#?
Answers : 6
An override method provides a new implementation of a member inherited from a base class. The method overridden by an override declaration is known as the overridden base method. The overridden base method must have the same signature as the override method.
Use the override modifier to modify a method, a property, an indexer, or an event. You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override.
   
Questions : 7 7. How can we check if all validation and controls are valid or proper?How can we force to run all validation control to run?
Answers : 7
By using Page.IsValid() property we can check if all validation and controls are valid or proper by using Page.Validate we can force to run all validation control to run
   
Questions : 8 What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?
Answers : 8
Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url. Response.Redirect is used to redirect the user's browser to another page or site. This performas a trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.
   
Questions : 9 What is JIT (just in time)? how it works?
Answers : 9
Before Microsoft intermediate language (MSIL) can be executed, it must be converted by a .NET Framework just-in-time (JIT) compiler to native code, which is CPU-specific code that runs on the same computer architecture as the JIT compiler. Rather than using time and memory to convert all the MSIL in a portable executable (PE) file to native code, it converts the MSIL as it is needed during execution and stores the resulting native code so that it is accessible for subsequent calls. The runtime supplies another mode of compilation called install-time code generation. The install-time code generation mode converts MSIL to native code just as the regular JIT compiler does, but it converts larger units of code at a time, storing the resulting native code for use when the assembly is subsequently loaded and executed. As part of compiling MSIL to native code, code must pass a verification process unless an administrator has established a security policy that allows code to bypass verification. Verification examines MSIL and metadata to find out whether the code can be determined to be type safe, which means that it is known to access only the memory locations it is authorized to access.
   
Questions : 10 Difference between DataReader and DataAdapter / DataSet and DataAdapter?
Answers : 10
You can use the ADO.NET DataReader to retrieve a read-only, forward-only stream of data from a database. Using the DataReader can increase application performance and reduce system overhead because only one row at a time is ever in memory. After creating an instance of the Command object, you create a DataReader by calling Command.ExecuteReader to retrieve rows from a data source, as shown in the following example. SqlDataReader myReader = myCommand.ExecuteReader(); You use the Read method of the DataReader object to obtain a row from the results of the query. while (myReader.Read()) Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0), myReader.GetString(1)); myReader.Close(); The DataSet is a memory-resident representation of data that provides a consistent relational programming model regardless of the data source. It can be used with multiple and differing data sources, used with XML data, or used to manage data local to the application. The DataSet represents a complete set of data including related tables, constraints, and relationships among the tables. The methods and objects in a DataSet are consistent with those in the relational database model. The DataSet can also persist and reload its contents as XML and its schema as XML Schema definition language (XSD) schema. The DataAdapter serves as a bridge between a DataSet and a data source for retrieving and saving data. The DataAdapter provides this bridge by mapping Fill, which changes the data in the DataSet to match the data in the data source, and Update, which changes the data in the data source to match the data in the DataSet. If you are connecting to a Microsoft SQL Server database, you can increase overall performance by using the SqlDataAdapter along with its associated SqlCommand and SqlConnection. For other OLE DB-supported databases, use the DataAdapter with its associated OleDbCommand and OleDbConnection objects.
   
Questions : 11 Differences between dataset.clone and dataset.copy?
Answers : 11
Clone - Copies the structure of the DataSet, including all DataTable schemas, relations, and constraints. Does not copy any data.
Copy - Copies both the structure and data for this DataSet.
   
Questions : 12 What is State Management in .Net and how many ways are there to maintain a state in .Net? What is view state?
Answers : 12
Web pages are recreated each time the page is posted to the server. In traditional Web programming, this would ordinarily mean that all information associated with the page and the controls on the page would be lost with each round trip. To overcome this inherent limitation of traditional Web programming, the ASP.NET page framework includes various options to help you preserve changes — that is, for managing state. The page framework includes a facility called view state that automatically preserves property values of the page and all the controls on it between round trips. However, you will probably also have application-specific values that you want to preserve. To do so, you can use one of the state management options.
Client-Based State Management Options:
View State
Hidden Form Fields
Cookies
Query Strings
Server-Based State Management Options
Application State
Session State
Database Support
   
Questions : 13 Difference between web services & remoting? Namespace?
Answers : 13
ASP.NET Web Services .NET Remoting Protocol Can be accessed only over HTTP Can be accessed over any protocol (including TCP, HTTP, SMTP and so on) State Management Web services work in a stateless environment Provide support for both stateful and stateless environments through Singleton and SingleCall objects Type System Web services support only the datatypes defined in the XSD type system, limiting the number of objects that can be serialized. Using binary communication, .NET Remoting can provide support for rich type system Interoperability Web services support interoperability across platforms, and are ideal for heterogeneous environments. .NET remoting requires the client be built using .NET, enforcing homogenous environment. Reliability Highly reliable due to the fact that Web services are always hosted in IIS Can also take advantage of IIS for fault isolation. If IIS is not used, application needs to provide plumbing for ensuring the reliability of the application. Extensibility Provides extensibility by allowing us to intercept the SOAP messages during the serialization and deserialization stages. Very extensible by allowing us to customize the different components of the .NET remoting framework. Ease-of-Programming Easy-to-create and deploy. Complex to program.
   
Questions : 14 What is MSIL, IL?
Answers : 14
When compiling to managed code, the compiler translates your source code into Microsoft intermediate language (MSIL), which is a CPU-independent set of instructions that can be efficiently converted to native code. MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations. Microsoft intermediate language (MSIL) is a language used as the output of a number of compilers and as the input to a just-in-time (JIT) compiler. The common language runtime includes a JIT compiler for converting MSIL to native code.
   
Questions : 15 What is strong name?
Answers : 15
A name that consists of an assembly's identity—its simple text name, version number, and culture information (if provided)—strengthened by a public key and a digital signature generated over the assembly.
   
Questions : 16 What is exception handling?
Answers : 16
When an exception occurs, the system searches for the nearest catch clause that can handle the exception, as determined by the run-time type of the exception. First, the current method is searched for a lexically enclosing try statement, and the associated catch clauses of the try statement are considered in order. If that fails, the method that called the current method is searched for a lexically enclosing try statement that encloses the point of the call to the current method. This search continues until a catch clause is found that can handle the current exception, by naming an exception class that is of the same class, or a base class, of the run-time type of the exception being thrown. A catch clause that doesn't name an exception class can handle any exception. Once a matching catch clause is found, the system prepares to transfer control to the first statement of the catch clause. Before execution of the catch clause begins, the system first executes, in order, any finally clauses that were associated with try statements more nested that than the one that caught the exception.
Exceptions that occur during destructor execution are worth special mention. If an exception occurs during destructor execution, and that exception is not caught, then the execution of that destructor is terminated and the destructor of the base class (if any) is called. If there is no base class (as in the case of the object type) or if there is no base class destructor, then the exception is discarded.
   
Questions : 17 What is the managed and unmanaged code in .net?
Answers : 17
The .NET Framework provides a run-time environment called the Common Language Runtime, which manages the execution of code and provides services that make the development process easier. Compilers and tools expose the runtime's functionality and enable you to write code that benefits from this managed execution environment. Code that you develop with a language compiler that targets the runtime is called managed code; it benefits from features such as cross-language integration, cross-language exception handling, enhanced security, versioning and deployment support, a simplified model for component interaction, and debugging and profiling services.
   
Questions : 18 What is the namespace threading in .net?
Answers : 18
System.Threading.Thread How to encode string string ss="pervej"; string encode=Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(ss)); Response.Write(encode)

INTERVIEWS QUESTION

What are Modal and Modeless forms in Windows Forms Application?

Modal Form:

In a modal form Windows application, the last form opened can only be accessed. i.e. the parent form cannot be accessed as long as the child form is open.

Modeless Form:

In case of Modeless form, Parent window generates a child window (as in Modal forms), but the user can access either of the Parent window or Child Window.



Dotnet Framework Interview Questions


This section contains Dotnet Framework Interview Questions that I faced in my interviews at the time of job change. Please post your comments here. Also, post your questions to get an answer.

1. What is an assembly in .Net? What is manifest?

2. What is GAC?

3. If you have two versions of the same assembly in GAC and you want to use the older version, how to achieve this?

4. What is side-by-side execution?

5. What is Reflection?

6. What is a satellite assembly?
Hint: Localization


C# Dotnet Interview questions



SQL Server Interview questions

This section will contain SQL Server Interview Questions and Answers. Please post your comments here. Also, post your questions to get an answer.

1. How to optimize stored procedures in SQL Server?
Ans: I. Use where clause
II. Select only required fields
III. Do join on indexed key fields

2. What is the difference between Stored procedure and User defined functions?

3. Why should we go for Stored Procedures? Why not direct queries?
Ans: SP are precompiled and contain an execution plan with it. Hence, they are faster.

4. How many NULL values we can have in a Unique key field in SQL Server?
Ans: Only one. In case of Oracle, we can have multiple NULL values in a Unique key field.

5. What is correlated subquery?
6. What is an index. What are the types?
Indexes in databases are very much similar to Indexes in Books. Indexes help in searching data faster.

Types: Clustered Index
Non-Clustered Index

7. What is the difference between a clustered index and a non-clustered index?
Clustered Index:
1 Only one clustered index allowed per table
2 Physically rearranges the data
3 For use on columns that are frequently searched for range of data

Non-clustered Index:
1 Upto 249 non-clustered index allowed per table
2 Doesn’t rearrange the data. Keeps a pointer to the data.
3 For use on columns that are searched for single value.

8. What is a join? What are the types of joins?
Joins are used to retrieve data from multiple tables.
Following are the types of joins:
Inner join
Left outer join
Right outer join
Full outer join
Cross join



9. What is a transaction?
A SQL transaction is a sequence of operations performed as a single unit of work. If all the tasks are completed successfully, then the transaction is committed (saved). If a single task fails, the transaction is rolled back (discarded).

10. What is ACID property of transaction?
A SQL transaction must exhibit ACID property, i.e Atomicity, Consistency, Isolation, and Durability.

Atomicity: A transaction is always treated as a single unit of work, i.e. either all the tasks are performed or none of them, no intermediate stage.
Consistency: When a transaction is completed, it must leave all data in a consistent state.
Isolation: Modifications made by a transaction must be isolated from the modifications made by other transactions.
Durability: After a transaction is completed, it’s effects are permanently in place in the system.

11. What is SET NOCOUNT ON?
When we perform a SELECT, INSERT, UPDATE or DELETE query, it returns a COUNT (number of rows affected) when SET NOCOUNT OFF. If SET NOCOUNT ON, it doesn’t return the COUNT.

12. How to delete exactly duplicate records from a table?
There are many ways. Simplest answer is:
i. Let the table tab1 contains duplicate records.
ii. Insert distinct records from tab1 in a temporary table #temp
INSERT INTO #temp
SELECT DISTINCT * FROM tab1
iii. Delete all rows from original table tab1
DELETE FROM tab1
iv. Insert from temporary table
INSERT INTO tab1
SELECT * FROM #temp
Try other solutions yourself.

13. How to get nth highest salary from employee table.
The query below demonstrates how to find the 5th highest salary. Replace 5 with any integer to get nth salary.

SELECT TOP 1 SALARY
FROM (SELECT DISTINCT TOP 5 SALARY
FROM EMPLOYEE ORDER BY SALARY DESC) a
ORDER BY SALARY ASC

What is the difference between web.config and machine.config


This is a common question asked in ASP.Net interviews.

Web.config and machine.config are two files used for managing configuration of web applications.

Machine.config:

1. The configurations mentioned in machine.config file are applicable to all the applications hosted in a machine/computer/server.

2. The machine.config file is located in x:\\Microsoft.NET\Framework\\config\machine.config

3. There can be only one machine.config file per machine (per dotnet framework installed).

web.config:

1. web.config file contains configurations for a single application.

2. Web.config files overrides the configurations mentioned in machine.config file.

3. The web configuration file is located in your application's root folder

4. There can be multiple web.config files in a single web application in different sub folders.

ONE YEAR EXP IN DOTNET QUESTION

Dotnet Framework Interview Questions for 1 Year Experience:

1. What is CLR and it's functions?
2. How memory is managed in Dotnet applications?
Hint: Automatically by Garbage collector
3. What is an assembly?
4. What is a strong name?
5. What is MSIL?

C# Interview Questions for 1 Year Experience:

1. What are the 4 pillars of Object Oriented Programming?
2. What is a Class? What is an Object?
3. What is a partial class?
4. What is a sealed class?
5. What is constructor?
6. What is stringbuilder?

ADO.Net Interview Questions for 1 Year Experience:

1. What is connection string?
2. What is Datareader?
3. Difference between Dataset and datareader?
4. What is Ado.Net?
5. Namespace for using sqlserver database?

ASP.Net Interview Questions for 1 Year Experience:

1. What is web.config file and it's use?
2. What is global.asax?
3. What is session?
4. Which all controls you have used in your project?
5. What is gridview?
6. What is Authentication in ASP.Net and types of authentication?

SQL Server Interview Questions for 1 Year Experience:

1. What is Primary key, unique key and difference between them?
2. What is index? Types of index?
3. What is a stored procedure? Why it is better than inline query?
Hint: Stored Procedure is precompiles and has a execution plan. Hence faster execution.
4. You might be asked to write simple query
5. What is inner join

Also, if you know any advance concepts like WCF, WPF, LINQ, MVC, JQuerymention while telling "about yourself". You will be given preference. But, make sure you know the basics or worked on them for sometime.

Tuesday 20 September 2011

download demo project

http://download.cnet.com/windows/3055-2229_4-10074675.html?tag=pdl-redir

8 Tips for Making Friends.


Groupoffriends
Every Wednesday is Tip Day.
This Wednesday: eight tips for making new friends.
Last week, I posted a list How to make friends -- or at least think about it more clearly. That list sets forth the "essential friendship skills."
But knowing the essential friendship skills isn't the same thing as being able to make friends. And friends are very important to happiness. The more I've studied happiness, in fact, the more convinced I've become that loneliness is a very common and very serious challenge to happiness. I think it's a subject that deserves more attention.
Ancient philosophers and contemporary scientists agree: strong social ties are a key -- arguably the key -- to happiness. You need close, long-term relationships; you need to be able to confide in others; you need to belong; you need to get and give support. Studies show that if you have five or more friends with whom to discuss an important matter you’re far more likely to describe yourself as “very happy.”
Not only does having strong relationships make it far more likely that you take joy in life, but studies show that it also lengthens life (incredibly, even more than stopping smoking), boosts immunity, and cuts the risk of depression.
But making friends can be difficult. Here are some strategies to try, if you’re eager to make friends but finding it tough:
1. Show up. Just as Woody Allen said that “Eighty percent of success is showing up,” a big part of friendship is showing up. Whenever you have the chance to see other people, take it. Go to the party. Stop by someone’s desk. Make the effort. I'm a big believer in the power of online tools like Facebook, Twitter, and Google+ to help sustain relationships, but nothing can replace a face-to-face meeting.
Also, the mere exposure effect describes the fact that repeated exposure makes you like someone better – and makes that person like you better, too. You’re much more likely to become friends with someone if you see him or her often. I’ve seen this happen over and over in my life. I’ve become close to unlikely people, just because circumstances put us in constant contact.
2. Join a group. Being part of a natural group, where you have common interests and are brought together automatically, is the easiest way to make friends: starting a new job, taking a class, having a baby, joining a congregation, or moving to a new neighborhood are great opportunities to join a group. If those situations aren’t an option, try to find a different group to join. Get a dog, for example. Or pursue a hobby more seriously. An added advantage to making friends through a group is that you'll have something obvious in common with these new acquaintances, and you can strengthen your friendships to several people at once -- very helpful if you don't have a lot of free time. Which is important, because for many people, lack of time is a real obstacle to making and sustaining friendships.
3. Form a group. If you can’t find an existing group to join, start a group based around something that interests you. My children's literature reading groups – (yes, now I’ve helped start three of these groups) are among the top joys of my life. Studies show that each common interest between people boosts the chances of a lasting relationship, and also brings about a 2% increase in life satisfaction, but I’m confident that my kidlit groups have given me a lift in life satisfaction much higher than two percent. Movies, wine, cheese, pets, marathon-training, a language, a worthy cause…I know people in all these sorts of groups. You can start a Happiness Project group! (If you want the starter kit, to help launching a group, email me at gretchenrubin1 at gretchenrubin dot com.)
4. Say nice things about other people. It’s a kind way to behave; also, studies show that because of the psychological phenomenon of spontaneous trait transference, people unintentionally transfer to you the traits you ascribe to other people. So if you tell Jean that Pat is arrogant, unconsciously Jean associates that quality with you. On the other hand, if you say that Pat is hilarious, you’ll be linked to that quality.
5. Set a target. This strategy sounds very calculating, but it has really worked for me. When I enter a situation where I meet a new set of people, I set myself the goal of making three new friends. This seems artificial, but somehow, this shift makes me behave differently, it makes me more open to people, it prompts me to make the effort to say more than a perfunctory hello.
6. Make an effort to smile. Big surprise, studies show that the amount of time you smile during a conversation has a direct effect on how friendly you’re perceived to be. In fact, people who can’t smile due to facial paralysis have trouble with relationships. I've been working hard on this myself lately; I've become more solemn over the years, or at least more distracted and tightly wound.
7. Make friends with friends-of-friends. “Triadic closure” is the term for the fact that people tend to befriend the friends of their friends. So friends-of-friends is an excellent place to start if you’re trying to expand your circle.
8. Be aware of cultural differences. On last week's post, a commenter noted that now that she lived in the United States, she missed the kind of easy, drop-by-your-house friendships that she'd had in Australia. She just didn't seem able to make those close friends. But I suspect that friendship intensity isn't the problem, just cultural practice. At least in Kansas City and New York City, the places I know best, even a very close friend wouldn't be likely to drop by your house unannounced -- no matter how those crazy kids behaved on the TV show Friends. So try to be aware of how friendship signals may be different in different places.
What other strategies have you used to help build friendship? And what challenges have you faced? The ones I hear the most are 1) lack of time and 2) new place with no network to draw upon. What about you?
* Yesterday, I tried ineffectually to describe to a friend the brilliance of TV Tropes. It's hard to explain, you just have to check it out yourself. It can also be a little hard to navigate, but stick with it -- it's worth it. For example, start with Characters or Fate and Prophecy, and dig in.

Tuesday 13 September 2011

Grouping and sorting throug Linq

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Movie
/// </summary>
public class Movie
{
    public string Title { get; set; }
    public string Director { get; set; }
    public int Genre { get; set; }
    public int RunTime { get; set; }
    public DateTime ReleaseDate{get;set;}

    public Movie()
    {
        //
        // TODO: Add constructor logic here
        //
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Movie1
/// </summary>
public class Movie1
{
    public int Genre { get; set; }
    public int MovieCount { get; set; }

   
    public Movie1()
    {
        //
        // TODO: Add constructor logic here
        //
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        var mo = GetMovies();
        Dictionary<int, Movie1> groups = new Dictionary<int, Movie1>();
        foreach (Movie m in mo)
        {

            if (!groups.ContainsKey(m.Genre))
            {
                groups[m.Genre] = new Movie1 { Genre = m.Genre, MovieCount = 0 };
            }
            groups[m.Genre].MovieCount++;

        }

        List<Movie1> results = new List<Movie1>(groups.Values);
        results.Sort(delegate(Movie1 x, Movie1 y)
        {
            return
                x.MovieCount > y.MovieCount ? -1 :
                x.MovieCount < y.MovieCount ? 1 : 0;
        });

        GridView1.DataSource = results;
        GridView1.DataBind();
    }
public List<Movie> GetMovies()
    {
    return new List<Movie> {new Movie {Title ="Ram", Director ="ABHI" ,Genre =0, ReleaseDate =DateTime.Parse ("05/12/2001"),RunTime =89},
        new Movie {Title ="Gopal",Director ="Rohit",Genre =1,ReleaseDate =DateTime .Parse ("4/12/2002"),RunTime =96},new Movie {Title ="Ram",Director ="AMIT", Genre =1,ReleaseDate =DateTime .Parse ("04/12/2011"),RunTime =34}
    };
   
    }
}

output-:
GenreMovieCount
12
01



LINQ with asp.net

.Net 3.5 introduced a new techonolgy  called Language Integrated Query or Linq(pronounced as "link")
LINQ includes three basic type of queries:
LINQ to Object;
LINQ to XML
and LINQ  used in the context of database ,like LINQ to SQL or LINQ  to ENTITES

LINQ to Object;

Example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Movie
/// </summary>
public class Movie
{
    public string Title { get; set; }
    public string Director { get; set; }
    public int Genre { get; set; }
    public int RunTime { get; set; }
    public DateTime ReleaseDate{get;set;}

    public Movie()
    {
        //
        // TODO: Add constructor logic here
        //
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        var mov = GetMovies();
        var qu = new List<Movie>();
        foreach (var m in mov)
        {
            if (m.Title =="Ram")
                qu.Add(m);
        }


        GridView1.DataSource = qu;
        GridView1.DataBind();
    }


    public List<Movie> GetMovies()
    {
    return new List<Movie> {new Movie {Title ="Ram", Director ="ABHI" ,Genre =0, ReleaseDate =DateTime.Parse ("05/12/2001"),RunTime =89},
        new Movie {Title ="Gopal",Director ="Rohit",Genre =1,ReleaseDate =DateTime .Parse ("4/12/2002"),RunTime =96},new Movie {Title ="Ram",Director ="AMIT", Genre =1,ReleaseDate =DateTime .Parse ("04/12/2011"),RunTime =34}
    };
   
    }
 

  

}

 Output:-
TitleDirectorGenreRunTimeReleaseDate
RamABHI0895/12/2001 12:00:00 AM
RamAMIT1344/12/2011 12:00:00 AM












Monday 12 September 2011

C#.Net Interview Questions and Answers


What Is NUnit?
Answer :: NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current
production release, version 2.2, is the fourth major release of this xUnit based unit testing tool for Microsoft
.NET. It is written entirely in C# and has been completely redesigned to take advantage of many .NET
language features, for example custom attributes and other reflection related capabilities. NUnit brings xUnit to
all .NET languages. .... Read More
In the NUnit test framework, which attribute must adorn a test class in order for it to be picked up by the NUnit GUI?
Answer :: I think it will be TestFixtureAttribute
The test fixture attribute is applied to a class that contains a suite of related test cases. If an error occurs while
initializing the fixture or if at least one of the test cases within the fixture fails, then the fixture itself will be
deemed to have failed. Otherwise the fixture will pass. Output from the fixture, such as text written to the
console, is captured by the framework and will be included in the test report.
A test fixture has no timeout by default. This may be changed using the TimeoutAttribute.
This attribute may be omitted whenever a test fixture class contains at least one test method or test parameter
or when other MbUnit attributes are applied to the test fixture class. This is almost always the case unless for
some reason you have an empty fixture.
The class must have a public default constructor. The class may not be static. .... Read More
When should you call the garbage collector in .NET?
Answer :: when Memory is low.... .... Read More
What is a satellite assembly?
Answer ::
<span style="font-size: 10pt; font-family: Verdana;">When you write a multilingual or multi-cultural application in
.NET, and want to distribute the core application separately from the localized modules, the localized
assemblies that modify the core application are called satellite assemblies.<o:p></o:p> .... Read More
What’s a multicast delegate?
Answer ::
<span style="font-size: 10pt; font-family: Verdana;">It&rsquo;s a delegate that points to and eventually fires off
several methods.<o:p></o:p> .... Read More
What’s a delegate?
Answer :: <span style="font-size: 10pt; font-family: Verdana;">A delegate object encapsulates a reference to a
method. .... Read More
What are the different ways a method can be overloaded?
Answer :: Different data types, different number, and different order of paramenter. .... Read More
How is method overriding different from method overloading?
No Accepted answer found .... View Answer
What’s the difference between an interface and abstract class?
No Accepted answer found .... View Answer
What is the difference between a Struct and a Class?
No Accepted answer found .... View Answer
What is an interface class?
No Accepted answer found .... View Answer
What’s an abstract class?
Answer :: Suppose you are implementing a new class that you want others to derive from. lets say...Car, the
abstract class might look something like this:
public abstract class Car
{
public abstract void RemoveAllFuses();
public abstract void StartEngine();
}
as you see, abstract class has methods that are NOT implemented, but just declared, the deriving class should
implement them.
The Car exaple here state an abstract Car, and its exactly what it is, abstract, a car with no name and no
functionality yet, but with some declaration on what it does (of course regular car has more than StartEngine
and RemoveAllFuses).
now each car who derive from the abstract one must implement both methods.
for example:
class Seat : Car
{
public override void RemoveAllFuses()
{
}
public override void StartEngine()
{
}
}
thats great...but now the question:
What should you do in order NOT to let a certain method withing the derived to be called?
eg, what whould you do to prevent this:
class MyCar : Seat
{
static void Main(string[] args)
{
MyCar c= new MyCar();
try
{
c.RemoveAllFuses();
}
catch (Exception e)
{
System.Console.WriteLine(e.Message);
}
}
}
you ask why? well, i say, Seat Car maker did not want to implement RemoveAllFuses.
the answer is really in the code, in the try block.
in the Seat Class, we should throw an exception in order to make that method unavailable, and at the same
time, we have actually implemented it. this is what you do if you DONT NEED ALL METHODS from a derived
class.
the modifed Seat class is:
class Seat : Car
{
public override void RemoveAllFuses()
{
throw new MethodAccessException();
}
public override void StartEngine()
{
}
}
MethodAccessException is being explained as "Attempt to access the method failed"...as simple as that.
.... Read More
What’s the C# syntax to catch any possible exception?
No Accepted answer found .... View Answer

LATEST DOTNET INTERVIEWS QUESTION


LATEST DOT NET INTERVIEW QUESTIONS


What are Design Patterns?
A Design Pattern essentially consists of a problem in a software design and a solution to the same.  In Design Patterns each pattern is described with its name, the motivation behind the pattern and its applicability.
According to MSDN, "A design pattern is a description of a set of interacting classes that provide a framework for a solution to a generalized problem in a specific context or environment. In other words, a pattern suggests a solution to a particular problem or issue in object-oriented software development.
Benefits of Design Patterns
The following are some of the major advantages of using Design Patterns in software development.
·   Flexibility                  ·   Adaptability to change                     ·   Reusability
When to use Design Patterns
Design Patterns are particularly useful in one of the following scenarios.
· When the software application would change in due course of time.
· When the application contains source code that involves object creation and event notification.
When not to use Design Patterns
. Do not use design patterns in any of the following situations.
· When the software being designed would not change with time.
· When the requirements of the source code of the application are unique.
If any of the above applies in the current software design, there is no need to apply design patterns in the current design and increase unnecessary complexity in the design.  
The Gang of Four (GOF) Patterns
The invention of the design patterns that we commonly use today can be attributed to the following four persons: Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. These men invented 23 patterns in all that are commonly known as the Gang of Four patterns or the GOF patterns.
·         Creational                       ·         Structural                       ·         Behavioral
Each of these groups in turn contains related sub patterns.  
Creational Patterns
The Creational Patterns deals with the best possible way of creating an object or an instance of a class.  They simplify object creation and provide a flexible approach towards object creation.  The following are the sub-patterns that fall under this group.
·   Abstract Factory       ·  Factory          ·   Builder         ·  Prototype      ·  Singleton

Both the Abstract Factory and the Factory pattern have the same intent.  
The Singleton Pattern indicates that there can be only one instance of a class throughout the Application’s life cycle.  A singleton class is one that can be instantiated only once in the application domain and provides a global point of access to it.

Structural Patterns
Structural Patterns provides the flexibility to specify how objects and classes can interoperate. The following are the sub patterns that comprise the Structural Patterns group.
·         Adapter              ·         Façade               ·         Bridge                ·         Composite
·         Decorator           ·         Flyweight           ·         Proxy                  ·         Adapter
·         Bridge                ·         Composite         ·         Decorator           ·         Flyweight
·         Proxy
Behavioral Patterns
Behavioral patterns help you define a structure for inter-object communication between objects in your system.  This design pattern is typically used to monitor the messages that are transmitted when the objects communicate in a system.  The following are the sub patterns under Behavioral Patterns.
·         Chain of Responsibility               ·         Command          ·         Interpreter         ·         Iterator
·         Mediator                         ·         Memento           ·         Observer            ·         State
·         Strategy             ·         Template Method           ·         Visitor

ASP.NET MVC is a framework that allows developers to apply the MVC pattern in the development of an ASP.NET application, thus allowing a better separation of concerns, which results in better reusability and easier testing.

MVC consists of three kinds of objects

The Model is an application object.

The View is the screen presentation.

The controller defines the way the user interface reacts to user inputs

·         The request comes from the client and hits the Controller.
·         The Controller calls the Model in order to perform some "business" operations.
·         The Model returns the results of the operations back to the Controller.
·         The Controller decides which View needs to be rendered and sends it the data that must be rendered.
·         Finally the View renders the output and sends the response back to the client.
What is Cryptography?
Cryptography is used to protect data and has many valuable uses. It can protect data from being viewed, modified, or to ensure the integrity from the originator. Cryptography can be used as a mechanism to provide secure communication over an unsecured network, such as the Internet, by encrypting data, sending it across the network in the encrypted state, and then the decrypting the data on the receiving end. Encryption can also be used as an additional security mechanism to further protect data such as passwords stored in a database to prevent them from being human readable or understandable.
Encryption Components
Encryption involves the use of a cryptography algorithm combined with a key to encrypt and decrypt the data. The goal of every encryption algorithm is to make it as difficult as possible to decrypt the data without the proper key. Data is translated from its originating form into something that appears meaningless unless the proper algorithm and key are used to decrypt the data.
The Microsoft .NET Framework classes (System.Security.Cryptography) will manage the details of cryptography for you. The classes are implemented with the same interface; so working with the classes is the same across the cryptography namespace.
Public-Key Encryption
Public-key encryption, also known as asymmetric encryption, uses a public and private key pair to encrypt and decrypt data. The public key is made available to anyone and is used to encrypt data to be sent to the owner of the private key. The private key, as the name implies, is kept private. The private key is used to decrypt the data and will only work if the correct public key was used when encrypting the data. The private key is the only key that will allow data encrypted with the public key to be decrypted. The keys can be stored for use multiple times, or generated for a one-time use.
Asymmetric encryption algorithms are usually efficient for encrypting small amounts of data only. The following public-key algorithms are available for use in the .NET Framework.
Digital Signature Algorithm (DSA)
RSA
Private-Key Encryption
Private-key Encryption, also known as symmetric encryption, uses a single key to encrypt and decrypt information. The key must be kept secret from those not authorized to decrypt the data lest the data be compromised. Private-key algorithms are relatively fast and can be used to encrypt and decrypt large streams of data. Private-key algorithms are known as block ciphers because they encrypt data one block at a time. A block cipher will encrypt the same input block into the same output block based on the algorithm and key. If the anything were known about the structure of the data, patterns could be detected and the key could possibly be reverse engineered. To combat this, the classes in the .NET Framework use a process known as chaining where information from the previous block is used in encrypting the current block. This helps prevent the key from being discovered. It requires an initialization vector (IV) be given to encrypt the first block of data.
The following private-key algorithms are available in the .NET Framework. Each description contains some basic information about each algorithm, including the strengths and weaknesses.
Data Encryption Standard (DES) algorithm encrypts and decrypts data in 64-bit blocks, using a 64-bit key. Even though the key is 64-bit, the effective key strength is only 56-bits. There are hardware devices advanced enough that they can search all possible DES keys in a reasonable amount of time. This makes the DES algorithm breakable, and the algorithm is considered somewhat obsolete.
RC2 is a variable key-size block cipher. The key size can vary from 8-bit up to 64-bits for the key. It was specifically designed as a more secure replacement to DES. The processing speed is two to three times faster than DES. However, the RC2CryptoServiceProvider available in the .NET Framework is limited to 8 characters, or a 64-bit key. The 8-character limitation makes it susceptible to the same brute force attack as DES.
TripleDES algorithm uses three successive iterations of the DES algorithm. The algorithm uses either two or three keys. Just as the DES algorithm, the key size is 64-bit per key with an effective key strength of 56-bit per key. The TripleDES algorithm was designed to fix the shortcomings of the DES algorithm, but the three iterations result in a processing speed three times slower than DES alone.
Rijndael algorithm, one of the Advanced Encryption Standard (AES) algorithms, was designed as a replacement for the DES algorithms. The key strength is stronger than DES, and was designed to out perform DES. The key can vary in length from 128, 192, to 256 bits in length. This is the algorithm I personally trust the most and that I'll use for the examples contained in the column.
Hashing Algorithms
No, I'm not talking about some type of drug related activity or an extra special recipe for brownies. Hashing refers to mapping data of any length into a fixed-length byte sequence. Regardless of if the input is the contents of the library of Congress or the typing test "The quick brown fox jumps over the lazy dog" it will result in an output of the same size. Hashing also produces unique results. Just as no two snowflakes are identical, no two combinations of input will produce the same hash output. Even if the input varies by a single character it will produce different output. The .NET Framework provides support for the following hash algorithms of which I'll leave it up to you to discover which one is right for you based on the size of the data you require.
HMACSHA1       MACTripleDES               MD5CryptoServiceProvider       SHA1Managed
SHA256Managed          SHA384Managed          SHA512Managed
How to Generate a Key and IV for Private-key Encryption
Each algorithm has specific key sizes that it expects for use. Each key must fit a predetermined size typically ranging from 1 character (8-bit) up to 32 characters (256-bit). Some of the algorithms support varying key sizes, but they must be within the valid ranges of key size for the particular algorithm. For our purposes, we'll use Rijndael, which supports 128, 192, and 256 bit keys. The way to generate a 128-bit key for use is through one of the hashing algorithms. A phrase, or "secret" of any length can be hashed to generate a key of the required size for encrypting data. The following code outlines a class containing a method that takes an input phrase and generates a key and IV for use.
Using Encryption to Protect Sensitive Data Stored in a Database
This brings us to a possible and often overlooked use for encryption, which is encrypting data such as passwords that are stored in a database. There are several benefits to storing sensitive data such as passwords in encrypted format.
It keeps sensitive application data such as passwords secret from those authorized to view data that ideally should not be able to see application specific data such as passwords.
It keeps passwords protected from unauthorized access. If the database is somehow compromised, the intruder must now the correct algorithm and key to decrypt the sensitive data.
Passing direct input to a query is dangerous because you never know what the input may contain. Suppose a stored procedure including something like "WHERE vc_Login = @Login and Password = @Password" is used for authentication. A user name of "'m' or 1=1" with the same for the password could evaluate to a true statement and result in incorrectly allowing access. If the user id and or password were stored encrypted then the data would not evaluate to a valid SQL statement because an encrypted form of the statement would be used in the evaluation.

22 New Features of Visual Studio 2008 for .NET Professionals

1. LINQ Support

LINQ essentially is the composition of many standard query operators that allow you to work with data in a more intuitive way regardless.

The benefits of using LINQ are significant – Compile time checking C# language queries, and the ability to debug step by step through queries.

2. Expression Blend Support

Expression blend is XAML generator tool for silverlight applications. You can install Expression blend as an embedded plug-in to Visual Studio 2008. By this you can get extensive web designer and JavaScript tool.

3. Windows Presentation Foundation

WPF provides you an extensive graphic functionality you never seen these before. Visual Studio 2008 contains plenty of WPF Windows Presentation Foundation Library templates. By this a visual developer who is new to .NET, C# and VB.NET can easily develop the 2D and 3D graphic applications.

Visual Studio 2008 provides free game development library kits for games developers. currently this game development kits are available for C++ and also 2D/3D Dark Matter one image and sounds sets.

4. VS 2008 Multi-Targeting Support

Earlier you were not able to working with .NET 1.1 applications directly in visual studio 2005. Now in Visual studio 2008 you are able to create, run, debug the .NET 2.0, .NET 3.0 and .NET 3.5 applications. You can also deploy .NET 2.0 applications in the machines which contains only .NET 2.0 not .NET 3.x.

5. AJAX support for ASP.NET

Previously developer has to install AJAX control library separately that does not come from VS, but now if you install Visual Studio 2008, you can built-in AJAX control library. This Ajax Library contains plenty of rich AJAX controls like Menu, TreeView, webparts and also these components support JSON and VS 2008 contains in built ASP.NET AJAX Control Extenders.

6. JavaScript Debugging Support

Since starting of web development all the developers got frustration with solving javascript errors. Debugging the error in javascript is very difficult. Now Visual Studio 2008 makes it is simpler with javascript debugging. You can set break points and run the javaScript step by step and you can watch the local variables when you were debugging the javascript and solution explorer provides javascript document navigation support.

7. Nested Master Page Support

Already Visual Studio 2005 supports nested master pages concept with .NET 2.0, but the problem with this Visual Studio 2005 that pages based on nested masters can't be edited using WYSIWYG web designer. But now in VS 2008 you can even edit the nested master pages.

8. LINQ Intellisense and Javascript Intellisense support for silverlight applications

Most happy part for .NET developers is Visual Studio 2008 contains intellisense support for javascript. Javascript Intellisense makes developers life easy when writing client side validation, AJAX applications and also when writing Silverlight applications

Intellisense Support: When we are writing the LINQ Query VS provides LINQ query syntax as tool tips.

9. Organize Imports or Usings

We have Organize Imports feature already in Eclipse. SInce many days I have been waiting for this feature even in VS. Now VS contains Organize Imports feature which removes unnecessary namespaces which you have imported. You can select all the namespaces and right click on it, then you can get context menu with Organize imports options like "Remove Unused Usings", "Sort Usings", "Remove and Sort". Refactoring support for new .NET 3.x features like Anonymous types, Extension Methods, Lambda Expressions.

10. Intellisense Filtering

Earlier in VS 2005 when we were typing with intellisense box all the items were being displayed. For example If we type the letter 'K' then intellisense takes you to the items starts with 'K' but also all other items will be presented in intellisense box. Now in VS 2008 if you press 'K' only the items starts with 'K' will be filtered and displayed.

11. Intellisense Box display position

Earlier in some cases when you were typing the an object name and pressing . (period) then intellisense was being displayed in the position of the object which you have typed. Here the code which we type will go back to the dropdown, in this case sometimes programmer may disturb to what he was typing. Now in VS 2008 If you hold the Ctrl key while the intellisense is dropping down then intellisense box will become semi-transparent mode.

12. Visual Studio 2008 Split View

VS 205 has a feature show both design and source code in single window. but both the windows tiles horizontally. In VS 2008 we can configure this split view feature to vertically, this allows developers to use maximum screen on laptops and wide-screen monitors.

Here one of the good feature is if you select any HTML or ASP markup text in source window automatically corresponding item will be selected in design window.

13. HTML JavaScript warnings, not as errors:

VS 2005 mixes HTML errors and C# and VB.NET errors and shows in one window. Now VS 2008 separates this and shows javascript and HTML errors as warnings. But this is configurable feature.

14. Debugging .NET Framework Library Source Code:

Now in VS 2008 you can debug the source code of .NET Framework Library methods. Lets say If you want to debug the DataBind() method of DataGrid control you can place a debugging point over there and continue with debug the source code of DataBind() method.

15. In built Silverlight Library

Earlier we used to install silverlight SDK separately, Now in VS 2008 it is inbuilt, with this you can create, debug and deploy the silverlight applications.

16. Visual Studio LINQ Designer

Already you know in VS 2005 we have inbuilt SQL Server IDE feature. by this you no need to use any other tools like SQL Server Query Analyzer and SQL Server Enterprise Manger. You have directly database explorer by this you can create connections to your database and you can view the tables and stored procedures in VS IDE itself. But now in VS 2008 it has View Designer window capability with LINQ-to-SQL.

17. Inbuilt C++ SDK

Earlier It was so difficult to download and configure the C++ SDK Libraries and tools for developing windows based applications. Now it is inbuilt with VS 2008 and configurable

18. Multilingual User Interface Architecture - MUI

MUI is an architecture contains packages from Microsoft Windows and Microsoft Office libraries. This supports the user to change the text language display as he wish.

Visual Studio is now in English, Spanish, French, German, Italian, Chinese Simplified, Chinese Traditional, Japanese, and Korean. Over the next couple of months. Microsoft is reengineering the MUI which supports nine local languages then you can even view Visual studio in other 9 local languages.

19. Microsoft Popfly Support

Microsoft Popfly explorer is an add-on to VS 2008, by this directly you can deploy or hosting the Silverlight applications and Marshup objects

Deployment Options Supported by .NET


You can deploy an ASP.NET Web application using any one of the following three deployment options.


XCOPY Deployment
Using the Copy Project option in VS .NET
Deployment using VS.NET installer

XCOPY Deployment


Before looking at how .NET enables XCOPY deployment, let us take a moment to understand what XCOPY deployment is. Prior to .NET, installing a component (for example, a COM Component) required copying the component to appropriate directories, making appropriate registry entries, and so on. But now in .NET, to install the component all you need to do is copy the assembly into the bin directory of the client application and the application can start using it right away because of the self-describing nature of the assembly. This is possible because compilers in the .NET Framework embed identifiers or meta-data into compiled modules and the CLR uses this information to load the appropriate version of the assemblies. The identifiers contain all the information required to load and run modules, and also to locate all the other modules referenced by the assembly. It is also refered to as zero-impact install since the machine is not impacted by way of configuring the registry entries and configuring the component. This zero-impact install also makes it possible to uninstall a component without impacting the system in any manner. All that is required to complete uninstallation is the removal of specific files from the specific directory. For performing this type of deployment, all you need to do is to go to the Command Prompt and copy over the required files to a specific directory on the server using the XCOPY command.

As you can see, the XCOPY command takes a number of arguments.

/ E - This option copies directories, subdirectories, and files of the source argument, including empty ones.
/ K - This option allows you to retain all the existing file and folder attributes. When you use XCOPY to copy files or a directory tree structure, XCOPY strips off file attributes by default. For example, if a file had the read-only attribute set, that attribute would be lost after the file is copied. To retain the original attributes with the copied files, you must use the / K parameter.
/ R - This option overwrites files marked as read only.
/ O - This option preserves all security-related permission ACLs of the file and folders.
/ H - This option copies both hidden and system files.
/ I - This option tells XCOPY to assume that the destination is a directory and create it if it does not already exist.

Once the folder is copied over to the target server, you then need to create a virtual directory on the target server (using Internet Information Manager MMC snap-in) and map that virtual directory to the physical directory that is created using the XCOPY command. That's all there is to deploying an ASP.NET Web application on a remote server using XCOPY Deployment.
Using the Copy Project Option in VS .NET
The Copy Project option in VS .NET makes it very easy to deploy ASP.NET Web applications onto the target servers. Using this option, you can copy the Web project to the same server or to a different server.

If you are using VS .NET to develop Web applicatons, the first thing that you need to do before packaging an ASP.NET Web applications is to change the Active Solution Configuration from Debug to Release as shown below. This allows the compiler not only to optimize the code but also remove the debugging related symbols from the code, making the code run much faster. To bring up the Configuration Manager, select your Web project from the Solution Explorer and select Project->Properties->Configuration Properties from the menu and then click on the Configuration Manager Command button. In the Active Solution Configuration combo box, select the Release option.

To copy the Web project onto the target server, select Project->Copy Project from the menu. Selecting that option will result in the following dialog box being displayed.

The Copy Project dialog provides the following options.

Destination Project Folder: Using this option, you can specify the location to which you want to copy the project. The location can be the same server or a remote server.
Web access method: The Web access method option determines the access method that is used to copy the Web project to the destination folder. There are two types of Web access methods.
File share: This option indicates that you want to directly access your project files on the Web server through a file share. It does not require FrontPage Server Extensions on the server.
FrontPage: This option specifies that you want to use the HTTP-based FrontPage Server Extensions to transfer your project files to the server. Before using this option, make sure FrontPage Server Extensions are installed on the server. This option will automatically create the required virtual directory on the target server.
Copy: The Copy option provides three types:
Only files needed to run this application: this option copies built output files (DLLs and references from the bin folder) and any content files (such as .aspx, .asmx files). Most of the time, you should be able to deploy the application using this default option.
All project files: this option copies built outputs (DLLs and references from the bin folder) and all files that are in the project. This includes the project file and source files.
All Files in the source project folder: choosing this option will result in all the project files and any other files that are in the project folder (or subfolder) being transferred to the destination folder.
To copy the Web project, select the appropriate options from the above Copy Project dialog box and click OK. This will result in the ASP.NET Web application being deployed on the target server.

Deployment Using VS .NET Web Setup Project


Even though XCOPY deployment and Copy Project options are very simple and easy-to-use, they do not lend themselves well to all of the deployment needs. For example, if your application requires more robust application setup and deployment requirements, VS .NET installer can be the right choice. Although you can distribute your Web application as a collection of build outputs, installer classes, and database creation scripts, it is often easier to deploy complex solutions with Windows Installer files. VS .NET provides Web setup projects that can be used to deploy Web applications. These Web setup projects differ from standard setup projects in that they install Web applications to a virtual root folder on a Web server rather than in the Program Files folder, as is the case with the applications installed using standard setup projects.
Since VS .NET installer is built on top of Windows Installer technology, it also takes advantages of Windows Installer features. Before starting on a discussion of VS .NET Web Setup Project, let us understand the architecture of Windows Installer technology that provides the core foundation on top of which the VS .NET installer is built.

Features Provided by VS .NET Web Setup Project


The deployment project in VS .NET builds on features of the Windows installer by allowing us to perform the following operations.

Reading or writing of registry keys
Creating directories in the Windows file system on the target servers
Provides a mechanism to register components
Provides a way to gather information from the users during installation
Allows you to set launch conditions, such as checking the user name, computer name, current operating system, software application installed, presence of .NET CLR and so on.
Also makes it possible to run a custom setup program or script after the installation is complete.
In the next section, we will see how to deploy our DeploymentExampleWebApp using the VS .NET Web Setup Project.

Creating a Web Setup Project Using VS .NET Installer


We will start by adding a new Web Setup Project to our DeploymentExampleWebApp ASP.NET Web application solution by selecting File->Add Project-> New Project from the menu. In the New Project dialog box, select Setup and Deployment Projects from the Project Types pane and then select Web Setup Project in the Templates pane as shown in the following figure.

After creating the project, you then need to add the output of the primary assembly and the content files of the ASP.NET Web application to the setup project. To do this, right click on the DeploymentExampleWebAppSetup project in the solution explorer and select Add->Project Output from the context menu. In the Add Project Output Group dialog box, select DeploymentExampleWebApp from the Project combo box and select Primary Output from the list.

After adding the project output, you then need to add the related Content Files (such as .aspx files, Images, and so on) to the project. To do this, again bring up the Add Project Output dialog box and then select Content Files from the list this time. It is illustrated in the following screenshot.

After adding the Primary output and the Content Files to the Web Setup project, the solution explorer looks as follows:

Configuring Properties through the Properties Window

There are a number of properties that you can set through the properties window of the Web Setup project. These properties determine the runtime display and behavior of the Windows installer file. To accomplish this, right click on the DeploymentExampleWebAppSetup project from the solution explorer and select Properties from the context menu to bring up its properties window. The dialog box shown below appears in the screen.

As can be seen from the above screenshot, the properties window provides properties such as Author, Description, Manufacturer, Support Phone and so on that can be very useful to the users (who are installing your application) of your application to get more details about your application.

Installing the ASP.NET Web Application


Once you have created the Windows installer file (.msi file), then installing the ASP.NET application in the target servers is very straightforward. All you need to do is to double-click on the .msi file from the Windows explorer. This will initiate the setup wizard, which will walk you through the installation steps. The following screenshot shows the first dialog box displayed during the installation.

Clicking on Next in the above dialog box results in the following dialog box, where you can specify the virtual directory that will be used to host this Web application. This is one of the handy features wherein the creation of virtual directory is completely automated obviating the need for manual intervention. In part two of this article, we will see how to set specific properties (such as Directory Security, Default Document and so on) on the virtual directory as part of the installation process.

In the above dialog box, you can also click on the Disk Cost... command button to get an idea of the space required for installing this Web application. Clicking on Next in the above dialog box results in the following dialog box where you are asked to confirm the installation.

When you click on Next in the above dialog box, the installation will begin and the application will be installed. If the application is successfully installed, you will see the following dialog box.

After installing the application, you can see the installed ASP.NET application through the Add/Remove Programs option (that can be accessed through Start->Settings->Control Panel) in your computer. From here, you can run the setup program to uninstall the application any time you want to.

Caching


The ability to store data in the main memory and then allow for retrieval of the same as and when they are requested.
Caching is a technique of persisting the data in memory for immediate access to requesting program calls.

ASP.NET supports three types of caching for Web-based applications:

1.    Page Level Caching (called Output Caching)
2.    Page Fragment Caching (often called Partial-Page Output Caching)
3.    Programmatic or Data Caching

Output Caching

Output caching caches the output of a page (or portions of it) so that a page's content need not be generated every time it is loaded.

In a typical ASP.NET page, every time the user views the page, the Web server will have to dynamically generate the content of the page and perform the relevant database queries (which are a very expensive task to do).

Considering the fact that the page does not change for a certain period of time, it is always a good idea to cache whatever is non-static so that the page can be loaded quickly.

In Page Output Caching, the entire page is cached in memory so all the subsequent requests for the same page are addressed from the cache itself.

In Page Fragment Caching, a specific a portion of the page is cached and not the entire page. Page Output or Fragment Caching can be enabled or disabled at the Page, Application or even the Machine levels.

Data Caching allows us to cache frequently used data and then retrieve the same data from the cache as and when it is needed. We can also set dependencies so that the data in the cache gets refreshed whenever there is a change in the external data store. The external data store can be a file or even a database. Accordingly, there are two types to dependencies, namely, file based and Sql Server based. There are also differing cache expiration policies

Syntax: <%@ OutputCache Duration="60" VaryByParam="none" %>

The above syntax specifies that the page be cached for duration of 60 seconds and the value "none" for VaryByParam* attribute makes sure that there is a single cached page available for this duration specified.

* VaryByParam can take various "key" parameter names in query string. Also there are other attributes like VaryByHeader, VaryByCustom etc.

The following is the complete syntax of page output caching directive in ASP.NET.

<%@ OutputCache Duration="no of seconds"
Location="Any | Client | Downstream | Server | None"
VaryByControl="control"
VaryByCustom="browser |customstring"
VaryByHeader="headers"
VaryByParam="parameter" %>

To store the output cache for a specified duration

Declarative Approach:

<%@ OutputCache Duration="60" VaryByParam="None" %>

Programmatic Approach:

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);

• To store the output cache on the browser client where the request originated

Declarative Approach:

<%@ OutputCache Duration="60" Location="Client" VaryByParam="None" %>

Programmatic Approach:

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Private);

• To store the output cache on any HTTP 1.1 cache-capable devices including the proxy servers and the client that made request

Declarative Approach:

<%@ OutputCache Duration="60" Location="Downstream" VaryByParam="None" %>

Programmatic Approach:

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetNoServerCaching();

• To store the output cache on the Web server

Declarative Approach:

<%@ OutputCache Duration="60" Location="Server" VaryByParam="None" %>

Programmatic Approach:

TimeSpan freshness = new TimeSpan(0,0,0,60);
DateTime now = DateTime.Now;
Response.Cache.SetExpires(now.Add(freshness));
Response.Cache.SetMaxAge(freshness);
Response.Cache.SetCacheability(HttpCacheability.Server);
Response.Cache.SetValidUntilExpires(true);

• To cache the output for each HTTP request that arrives with a different City:

Declarative Approach:

<%@ OutputCache duration="60" varybyparam="City" %>

Programmatic Approach:

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.VaryByParams["City"] = true;

For the VaryByCustom attribute, the VaryByHeader attribute, and the VaryByParam attribute in the @ OutputCache directive, the HttpCachePolicy class provides the VaryByHeaders property and the VaryByParams
property, and the SetVaryByCustom method.

1. Page Output Caching

In Page Output Caching, the entire page is cached in memory so all the subsequent requests for the same page are addressed from the cache itself.

Partial-Page Output Caching/ Page Fragment Caching

In Page Fragment Caching, a specific a portion of the page is cached and not the entire page. Page Output or Fragment Caching can be enabled or disabled at the Page, Application or even the Machine levels.

More often than not, it is impractical to cache entire pages. For example, you may have some content on your page that is fairly static, such as a listing of current inventory, but you may have other information, such as the user's shopping cart, or the current stock price of the company, that you wish to not be cached at all. Since Output Caching caches the HTML of the entire ASP.NET Web page, clearly Output Caching cannot be used for these scenarios: enter Partial-Page Output Caching.

Partial-Page Output Caching, or page fragment caching, allows specific regions of pages to be cached.

fragment caching comes from the attribute "VaryByControl". Using this attribute one can cache a user control based on the properties exposed.

Syntax: <%@ OutputCache Duration="60" VaryByControl="DepartmentId" %>

The above syntax when declared within an *.ascx file ensures that the control is cached for 60 seconds and the number of representations of cached control is dependant on the property "DepartmentId" declared in the control.

Data Caching

Programmatic or data caching takes advantage of the .NET Runtime cache engine to store any data or object between responses. That is, you can store objects into a cache, similar to the storing of objects in Application scope in classic ASP.

Realize that this data cache is kept in memory and "lives" as long as the host application does. In other words, when the ASP.NET application using data caching is restarted, the cache is destroyed and recreated. Data Caching is almost as easy to use as Output Caching or Fragment caching: you simply interact with it as you would any simple dictionary object.

Note that the Insert method allows you to simply add items to the cache using a key and value notation as well. For example to simply add an instance of the object bar to the cache named foo, use syntax like this:

Cache.Insert("foo", bar); // C#
Cache.Insert("foo", bar) ' VB.NET

Question - Define Caching in ASP.NET.
Answer -  Caching technique allows to store/cache page output or application data on the client. The cached information is used to serve subsequent requests that avoid the overhead of recreating the same information. This enhances performance when same information is requested many times by the user. 


Question - Advantages of Caching
Answer -  It increases performance of the application by serving user with cached output.
It decreases server round trips for fetching data from database by persisting data in the memory.
It greatly reduces overhead from server resources.

Question - What are the types of Caching in ASP.NET?
Answer - Caching in ASP.NET can be of the following types
Page Output Caching
Page Fragment Caching
Data Caching

Question - Explain in brief each kind of caching in ASP.NET.
Answer -  Page Output Caching
This type of caching is implemented by placing OutputCache directive at the top of the .aspx page at design time.
For example:
<%@OutputCache Duration= "30" VaryByParam= "DepartmentId"%>

The duration parameter specifies for how long the page would be in cache and the VaryByParam parameter is used to cache different version of the page.
The VaryByParam parameter is useful when we require caching a page based on certain criteria.

Page Fragment Caching
This technique is used to store part of a Web form response in memory by caching a user control.

Data Caching
Data Caching is implemented by using Cache object to store and quick retrieval of application data.
Cache object is just like application object which can be access anywhere in the application.
The lifetime of the cache is equivalent to the lifetime of the application.

Question:-What do you mean by Share Point Portal ?
Answer:
Here I have taken information regarding Share Point Portal Server 2003 provides mainly access to the crucial business information and applications. With the help of Share Point Server we can server information between Public Folders, Data Bases, File Servers and the websites that are based on Windows server 2003. This Share Point Portal is integrated with MSAccess and Windows servers, So we can get a Wide range of document management functionality. We can also create a full featured portal with readymade navigation and structure.
Question:-What is cross page posting in ASP.NET2.0 ?
Answer:
When we have to post data from one page to another in application we used server.transfer method but in this the URL remains the same but in cross page posting there is little different there is normal post back is done but in target page we can access values of server control in the source page.This is quite simple we have to only set the PostBackUrl property of Button,LinkButton or imagebutton which specifies the target page. In target page we can access the PreviousPage property. and we have to use the @PreviousPageType directive. We can access control of PreviousPage by using the findcontrol method. When we set the PostBackURL property ASP.NET framework bind the HTML and Javascript function automatically.
Question: How to start Outlook,NotePad file in AsP.NET with code ?
Answer:
Here is the syntax to open outlook or notepad file in ASP.NET VB.NET Process.Start("Notepad.exe") Process.Start("msimn.exe"); C#.NET System.Diagnostics.Process.Start("msimn.exe"); System.Diagnostics.Process.Start("Notepad.exe");

Question: What is the purpose of IIS ?
Answer:
We can call IIS(Internet Information Services) a powerful Web server that helps us creating highly reliable, scalable and manageable infrastructure for Web application which runs on Windows Server 2003. IIS helps development center and increase Web site and application availability while lowering system administration costs. It also runs on Windows NT/2000 platforms and also for above versions. With IIS, Microsoft includes a set of programs for building and administering Web sites, a search engine, and support for writing Web-based applications that access database. IIS also called http server since it process the http request and gets http response.

Question: What is main difference between GridLayout and FormLayout ?
Answer:
GridLayout helps in providing absolute positioning of every control placed on the page. It is easier to develop page with absolute positioning because control can be placed any where according to our requirement. But FormLayout is little different only experience Web Developer used this one reason is it is helpful for wider range browser. If there is absolute positioning we can notice that there are number of DIV tags. But in FormLayout whole work are done through the tables.

Question: How Visual SourceSafe helps Us ?
Answer:
One of the powerful tool provided by Microsoft to keep up-to-date of files system its keeps records of file history once we add files to source safe it can be add to database and the changes ads by different user to this files are maintained in database from that we can get the older version of files to. This also helps in sharing,merging of files.

Question:-Can you define what is SharePoint and some overview about this ?
Answer:
SharePoint helps workers for  creating  powerful personalized interfaces only by dragging and drop pre-defined Web Part Components. And these Web Parts components also helps non programmers to get information which care  and customize the appearance of Web pages. To under stand it we take an example  one Web Part might display a user's information another might create a graph showing current employee status  and a third might show a list of Employees Salary. This is also possible that each functions has a link to a video or audio presentation. So now  Developers are unable to  create these Web Part components and make them available to SharePoint users.

Question:-What is different between WebUserControl and in WebCustomControl ?

Answer: Web user controls :- Web User Control is Easier to create and another thing is that its support is limited for users who use a visual design tool one good thing is that its contains static layout one more thing a separate copy is required for each application.
Web custom controls:-Web Custom Control is typical to create and good for dynamic layout and another thing is it have full tool support for user and a single copy of control is required because it is placed in Global Assembly cache.

Question:-What is Sandbox in SQL server and explain permission level in Sql Server ?
Answer: Sandbox is place where we run trused program or script which is created  from the third party. There are three type of Sandbox where user code run.
Safe Access Sandbox:-Here we can only create stored procedure,triggers,functions,datatypes etc.But we doesnot have acess memory ,disk etc.
External Access Sandbox:-We cn access File systems outside the box. We can not play with threading,memory allocation etc.
Unsafe Access Sandbox:-Here we can write unreliable and unsafe code.

Question:-How many types of cookies are there in .NET ?
Answer:
Two type of cookeies.
a) single valued eg request.cookies(”UserName”).value=”dotnetquestion”
b)Multivalued cookies. These are used in the way collections are used example
request.cookies(”CookiName”)(”UserName”)=”dotnetquestionMahesh”
request.cookies(”CookiName”)(”UserID”)=”interview″

Question: When we get Error 'HTTP 502 Proxy Error' ?
Answer:
We get this error when we execute ASP.NET Web pages in Visual Web Developer Web server, because the URL randomly select port number and proxy servers did not recognize the URL and return this error. To resolve this problem we have to change settings in Internet Explorer to bypass the proxy server for local addresses, so that the request is not sent to the proxy.

Question:-What do you mean by three-tier architecture?
Answer: The three-tier architecture was comes into existence to improve management of code and contents and to improve the performance of the web based applications. There are mainly three layers in three-tier architecture. the are define as follows

(1)Presentation
(2)Business Logic
(3)Database

(1)First layer Presentation contains mainly the interface code, and this is shown to user. This code could contain any technology that can be used on the client side like HTML, JavaScript or VBScript etc.

(2)Second layer is Business Logic which contains all the code of the server-side .This layer have code to interact with database and to query, manipulate, pass data to user interface and handle any input from the UI as well.

(3)Third layer Data represents the data store like MS Access, SQL Server, an XML file, an Excel file or even a text file containing data also some additional database are also added to that layers.

Question: What is Finalizer in .NET define Dispose and Finalize?
Answer:
We can say that Finalizer are the methods that's helps in cleanp the code that is executed before object is garbage collected .The process is called finalization . There are two methods of finalizer Dispose and Finalize .There is little diffrenet between two of this method .
When we call Dispose method is realse all the resources hold by an object as well as all the resorces hold by the parent object.When we call Dispose method it clean managed as well as unmanaged resources.
Finalize methd also cleans resources but finalize call dispose clears only the unmanged resources because in finalization the garbase collecter clears all the object hold by managed code so finalization fails to prevent thos one of methd is used that is: GC.SuppressFinalize.

Question: What is late binding ?
Answer:
When code interacts with an object dynamically at runtime .because our code literally doesnot care what type of object it is interacting and with the methods thats are supported by object and with the methods thats are supported by object .The type of object is not known by the IDE or compiler ,no Intellisense nor compile-time syntax checking is possible but we get unprecedented flexibilty in exchange.if we enable strict type checking by using option strict on at the top of our code modules ,then IDE and compiler will enforce early binding behaviour .By default Late binding is done.

Question:-Does .NET CLR and SQL SERVER run in different process?
Answer:
Dot Net CLR and all .net realtes application and Sql Server run in same process or we can say that that on the same address because there is no issue of speed because if these two process are run in different process then there may be a speed issue created one process goes fast and other slow may create the problem.

Question: The IHttpHandler and IHttpHandlerFactory interfaces ?
Answer:
The IHttpHandler interface is implemented by all the handlers. The interface consists of one property called IsReusable. The IsReusable property gets a value indicating whether another request can use the IHttpHandler instance. The method ProcessRequest() allows you to process the current request. This is the core place where all your code goes. This method receives a parameter of type HttpContext using which you can access the intrinsic objects such as Request and Response. The IHttpHandlerFactory interface consists of two methods - GetHandler and ReleaseHandler. The GetHandler() method instantiates the required HTTP handler based on some condition and returns it back to ASP.NET. The ReleaseHandler() method allows the factory to reuse an existing handler.

Question: what is Viewstate?
Answer:
View state is used by the ASP.NET page framework to automatically save the values of the page and of each control just prior to rendering to the page. When the page is posted, one of the first tasks performed by page processing is to restore view state.
State management is the process by which you maintain state and page information over multiple requests for the same or different pages.

Client-side options are:

* The ViewState property        * Query strings                        * Hidden fields                         * Cookies

Server-side options are:

* Application state                   * Session state                                    * DataBase

Use the View State property to save data in a hidden field on a page. Because ViewState stores data on the page, it is limited to items that can be serialized. If you want to store more complex items in View State, you must convert the items to and from a string.
ASP.NET provides the following ways to retain variables between requests:
Context.Handler object Use this object to retrieve public members of one Web form’s class from a subsequently displayed Web form.
Query strings Use these strings to pass information between requests and responses as part of the Web address. Query strings are visible to the user, so they should not contain secure information such as passwords.
Cookies Use cookies to store small amounts of information on a client. Clients might refuse cookies, so your code has to anticipate that possibility.
View state
ASP.NET stores items added to a page’s ViewState property as hidden fields on the page.
Session state Use Session state variables to store items that you want keep local to the current session (single user).
Application state Use Application state variables to store items that you want be available to all users of the application.

Describe the security authentication flow and process in ASP.NET?


When a user requests a web page, there exists a process of security too, so that every anonymous user is checked for authentication before gaining access to the webpage. The following points are followed in the sequence for authentication when a client attempts a page request:

·         A .aspx web page residing on an IIS web server is requested by an end user
·         IIS checks for the user's credentials
·         Authentication is done by IIS. If authenticated, a token is passed to the ASP.NET worker process along with the request
·         Based on the authentication token from IIS, and on the web.config settings for the requested resource, ASP.NET impersonates the end user to the request thread. For impersonation, the web.config impersonate attribute's value is checked.

What is Authentication? What are the different types of Authentication?

In a client-server environment, there are plenty of cases where the server has to interact and identify the client that sends a request to the server. Authentication is the process of determining and confirming the identity of the client.

If a client is not successfully identified, it is said to be anonymous.

Windows Authentication          Forms Authentication  Passport Authentication

Essentially the Windows Authentication and Forms Authentication are the famous ones, as Passport Authentication is related to a few websites (like microsoft.com, hotmail.com, msn.com etc. only).

Windows Authentication is implemented mostly in Intranet scenarios. When a browser (client) sends a Request to a server where in windows authentication has been implemented, the initial request is anonymous in nature. The server sends back a Response with a message in HTTP Header. This Prompts a Window to display a Modal Dialog Box on the browser, where the end user may enter the "User name" and "Password".

The end user enters the credentials, which are then validated against the User Store on the Windows server. Note that each user who access the Web Application in a Windows Authentication environment needs to have a Windows Account in the company network.

How to avoid or disable the modal dialog box in a Windows Authentication environment?
By enabling the Windows Integrated Authentication checkbox for the web application through settings in IIS.

Forms Authentication is used in Internet based scenarios, where its not practical to provide a Windows based account to each and every user to the Web Server. In a Forms Authentication environment, the user enters credentials, usually a User Name and a corresponding Password, which is validated against a User Information Store, ideally a database table.

Forms Authentication Ticket is the cookie stored on the user's computer, when a user is authenticated. This helps in automatically logging in a user when he/she re-visits the website. When a Forms Authentication ticket is created, when a user re-visits a website, the Forms Authentication Ticket information is sent to the Web Server along with the HTTP Request.

Describe the Provider Model in ASP.NET 2.0?

The Provider model in ASP.NET 2.0 is based on the Provider Design Pattern that was created in the year 2002 and later implemented in the .NET Framework 2.0.

The Provider Model supports automatic creation of users and their respective roles by creating entries of them directly in the SQL Server (May even use MS Access and other custom data sources). So actually, this model also supports automatically creating the user table's schema.

The Provider model has 2 security providers in it: Membership provider and Role Provider. The membership provider saves inside it the user name (id) and corresponding passwords, whereas the Role provider stores the Roles of the users.

For SQL Server, the SqlMembershipProvider is used, while for MS Access, the AccessMembershipProvider is used. The Security settings may be set using the website adminstration tool. Automatically, the AccessMembershipProvider creates a Microsoft Access database file named aspnetdb.mdb inside the application's App_Data folder. This contains 10 tables.

Describe the Personalization in ASP.NET 2.0?

ASP.NET 2.0 Personalization - Personalization allows information about visitors to be persisted on a data store so that the information can be useful to the visitor when they visit the site again. In ASP.NET 2.0, this is controlled by a Personalization API. Before the Personalization Model came into existence, the prior versions of ASP.NET used of the old Session object to take care of re-visits. Now comes the Profile object.

In order to use a Profile object, some settings need to be done in web.config. The example below shall explain how to use a profile object:

//Add this to System.Web in web.config

<profile>
<properties>
  <add name="FirstName" type="System.String"/>
</properties>
</profile>

'In Page_Load event, add the following...

If Profile.FirstName <> "" Then
   Panel1.Visible = False
   Response.Write("Welcome Back Dear :, " & Profile.FirstName & ", " & Profile.LastName)
Else
   Panel1.Visible = True
End If

'Here is the code how to save the profile properties in an event to save it
Profile.FirstName = txtFirstName.Text

Explain about Generics?


Generics are not a completely new construct; similar concepts exist with other languages. For example, C++ templates can be compared to generics. However, there's a big difference between C++ templates and .NET generics. With C++ templates the source code of the template is required when a template is instantiated with a specific type. Contrary to C++ templates, generics are not only a construct of the C# language; generics are defined with the CLR. This makes it possible to instantiate generics with a specific type in Visual Basic even though the generic class was defined with C#.

Why we use Serialization?

Serialization of data using built-in .NET support makes persistence easy and reusable.

Most uses of serialization fall into two categories: persistence and data interchange. Persistence allows us to store the information on some non-volatile mechanism for future use. This includes multiple uses of our application, archiving, and so on. Data interchange is a bit more versatile in its uses. If our application takes the form of an N-tier solution, it will need to transfer information from client to server, likely using a network protocol such as TCP. To achieve this we would serialize the data structure into a series of bytes that we can transfer over the network. Another use of serialization for data interchange is the use of XML serialization to allow our application to share data with another application altogether. As you can see, serialization is a part of many different solutions within our application.

What is Serialization?

Serialization is the process of converting an object, or group of objects, into a form that can be persisted. When u serialize an object, you also serialize the values of its properties.

How Do You Use Serialization?

Serialization is handled primarily by classes and interfaces in the System.Runtime.Serialization namespace. To serialize an object, you need to create two things:
  • A stream to contain the serialized objects.
  • A formatter to serialize the objects into the stream.

The Role of Formatters in .NET Serialization

A formatter is used to determine the serialized format for objects. All formatters expose the IFormatter interface, and two formatters are provided as part of the .NET framework:
  • BinaryFormatter provides binary encoding for compact serialization to storage, or for socket-based network streams. The BinaryFormatter class is generally not appropriate when data must be passed through a firewall.
  • SoapFormatter provides formatting that can be used to enable objects to be serialized using the SOAP protocol. The SoapFormatter class is primarily used for serialization through firewalls or among diverse systems. The .NET framework also includes the abstract Formatter class that may be used as a base class for custom formatters. This class inherits from the IFormatter interface, and all IFormatter properties and methods are kept abstract, but you do get the benefit of a number of helper methods that are provided for you.