Projects

abhijihttp://www.codeproject.com/KB/aspnet/ExploringSession.aspx
http://abhijitjana.net/
my csshttp://www.jotform.commy 
hosthttp://www.free-webhosts.com/search-webhosts.php?SA=asp.net
http://www.free-css.com/free-website-templates/page5.php#bookmarks
mindblowing:http://www.wibiya.com/
wpfvideoplayer  http://blogs.microsoft.co.il/blogs/davids/archive/2009/05/17/mediaelement-and-more-with-wpf.aspx

log.reg.fphttp://tympanus.net/codrops/2011/01/06/animated-form-switching/
http://www.noupe.com/php/beautiful-forms.html
gravhttp://www.9lessons.info/2011/01/gravity-registration-form-with-jquery.html
typehttp://www.tutorialshock.com/tutorials/jquery-contact-form/

http://www.css3menu.com/
http://www.templatemo.com/
mytemp

How to Freeze GridView Header While Scrolling ?

  
This is very common problem in Web development that we need to freeze the GridView header at the time of scrolling, Here is one simple tips:

Step 1 : Create a CSS class as following

 <br />.HeaderFreez <br />{ <br />position:relative ; <br />top:expression(this.offsetParent.scrollTop); <br />z-index: 10; <br />} <br />

 Step 2 Set Gridview’s HeaderStyle CssClass as follows 

CssClass="HeaderFreez"
You can't even declare private virtual methods. The only time it would make any sense at all would be if you had:

public class Outer
{
    private virtual void Foo() {}

    public class Nested : Outer
    {
        private override void Foo() {}
    }
}

... that's the only scenario in which a type has access to its parent's private members. However, this is still prohibited:

    Test.cs(7,31): error CS0621: 'Outer.Nested.Foo()': virtual or abstract members cannot be private
    Test.cs(3,26): error CS0621: 'Outer.Foo()': virtual or abstract members cannot be private








Re: What is namespace used for loading assemblies at run time and name the methods?
Answer
# 2    

System.Reflection and System.Type.InvokeMember to invoke
the me
services 

How do I copy or move a file from one location to another?


The File class contains a Copy() method to copy a file from one location to another. The Copy() method can accept either two or three input parameters. The first two (required) input parameters are strings and specify the source file name and the destination file name, respectively. An example of using the Copy() method can be seen below:

' VB.NET
File.Copy("C:\Dir1\SomeFile.txt", "C:\SomeOtherDir\SomeFile.txt")

// C#
File.Copy("C:\\Dir1\\SomeFile.txt", @"C:\SomeOtherDir\SomeFile.txt");


(Note that in the C# source code the backslash must be escaped by the use of two successive backslashes. However, if the string literal is preceded by an at sign (@), then escape sequences are not processed, and therefore you do not need to escape the single backslash.)

The Copy() method also has a third, optional parameter, a Boolean value that indicates what to do if there already exists a file at the specified destination path. If the third parameter is set to True, then the existing file is overwritten, otherwise, if the parameter is set to False, an IOException is thrown. An example of using this optional form of the Copy() method is shown below:

' VB.NET - copy with overwrite
File.Copy("C:\Dir1\SomeFile.txt", "C:\SomeOtherDir\SomeFile.txt", True)

// C# - copy without overwrite
File.Copy("C:\\Dir1\\SomeFile.txt", @"C:\SomeOtherDir\SomeFile.txt", false);


A couple important things to realize when copying files via the Copy() method:

-- The destination path must contain a filename; that is, you cannot specify just a directory path as the Copy() method's second parameter.

-- The source and destination paths cannot be the same

-- The destination path name cannot contain any invalid file path characters (such as <, >, ?, |, etc.)


Moving a File
To move a file from one location to another, use the File.Move() method. The Move() method accepts precisely two string input parameters, the source file path and destination file path. An example of the Move() method in action is shown below:

' VB.NET
File.Move("C:\Dir1\SomeFile.txt", "C:\SomeOtherDir\SomeFile.txt")

// C#
File.Move("C:\\Dir1\\SomeFile.txt", @"C:\SomeOtherDir\SomeFile.txt");


Realize that moving a file from a source location to a destination location removes the file from the source location and places it in the destination location. Copying a file simply creates a duplicate copy of the source location at the destination location.

Also, entire directories can be moved using the Directory.Move() method. The Directory.Move() method, just like the File.Move() method, accepts precisely two input parameters: the source path and the destination path, respectively.


Closing Comments...
The File class is located in the System.IO namespace, meaning that you will have to import this namespace into your ASP.NET Web page or code-behind class. If you are using a server-side script block in your ASP.NET Web page, add <%@ Import Namespace="System.IO" %> to the top of the ASP.NET Web page. If you are using a code-behind class, add the following:

' VB.NET
Imports System.IO


// C#
using System.IO;

Realize that you can easily translate a virtual path, like /files/SomeFile.aspx to its corresponding physical path, say C:\InetPub\wwwroot\files\SomeFile.aspx using the Server.MapPath() method. For more information on Server.MapPath()

                                                       WCF

 

 Q1. What is WCF?
WCF stands for Windows Communication Foundation. It is a Software development kit for developing services on Windows. WCF is introduced in .NET 3.0. in the System.ServiceModel namespace. WCF is based on basic concepts of Service oriented architecture (SOA)

Q2. What is endpoint in WCF service?
The endpoint is an Interface which defines how a client will communicate with the service. It consists of three main points: Address,Binding and Contract.

Q3. Explain Address,Binding and contract for a WCF Service?
Address:Address defines where the service resides.
Binding:Binding defines how to communicate with the service.
Contract:Contract defines what is done by the service.

Q4. What are the various address format in WCF?
a)HTTP Address Format:--> http://localhost:
b)TCP Address Format:--> net.tcp://localhost:
c)MSMQ Address Format:--> net.msmq://localhost:

Q5. What are the types of binding available in WCF?
A binding is identified by the transport it supports and the encoding it uses. Transport may be HTTP,TCP etc and encoding may be text,binary etc. The popular types of binding may be as below:
a)BasicHttpBinding
b)NetTcpBinding
c)WSHttpBinding
d)NetMsmqBinding

Q6. What are the types of contract available in WCF?
The main contracts are:
a)Service Contract:Describes what operations the client can perform.
b)Operation Contract : defines the method inside Interface of Service.
c)Data Contract:Defines what data types are passed
d)Message Contract:Defines wheather a service can interact directly with messages

Q7. What are the various ways of hosting a WCF Service?
a)IIS b)Self Hosting c)WAS (Windows Activation Service)

Q8. WWhat is the proxy for WCF Service?
A proxy is a class by which a service client can Interact with the service.
By the use of proxy in the client application we are able to call the different methods exposed by the service


Q9. How can we create Proxy for the WCF Service?
We can create proxy using the tool svcutil.exe after creating the service.
We can use the following command at command line.
svcutil.exe *.wsdl *.xsd /language:C# /out:SampleProxy.cs /config:app.config

Q10.What is the difference between WCF Service and Web Service?
a)WCF Service supports both http and tcp protocol while webservice supports only http protocol.
b)WCF Service is more flexible than web service.

Q11.What is DataContract and ServiceContract?Explain
Data represented by creating DataContract which expose the
data which will be transefered /consumend from the serive
to its clients.
Code:
[ServiceContract]
Public Interface IEmpOperations
{
[OperationContract]
Decimal Get EmpSal(int EmpId);

}

Class MyEmp: IEmpOperations
{
Decimal Get EmpSal()
{
// Implementation of this method.
}
}



1. What is the difference between WCF and ASMX Web Services?
Simple and basic difference is that ASMX or ASP.NET web service is designed to send and receive messages using SOAP over HTTP only. While WCF can exchange messages using any format (SOAP is default) over any transport protocol (HTTP, TCP/IP, MSMQ, NamedPipes etc).

Another tutorial WCF Vs ASMX has detailed discussion on it.
2. What are WCF Service Endpoints? Explain.
For Windows Communication Foundation services to be consumed, it’s necessary that it must be exposed; Clients need information about service to communicate with it. This is where service endpoints play their role.

A WCF service endpoint has three basic elements i.e. Address, Binding and Contract.

     Address: It defines "WHERE". Address is the URL that identifies the location of the service.
     Binding: It defines "HOW". Binding defines how the service can be accessed.
    Contract: It defines "WHAT". Contract identifies what is exposed by the service.

3. What are the possible ways of hosting a WCF service? Explain.

For a Windows Communication Foundation service to host, we need at least a managed process, a ServiceHost instance and an Endpoint configured. Possible approaches for hosting a service are:

    Hosting in a Managed Application/ Self Hosting
        Console Application
        Windows Application
        Windows Service
    Hosting on Web Server
        IIS 6.0 (ASP.NET Application supports only HTTP)
        Windows Process Activation Service (WAS) i.e. IIS 7.0 supports HTTP, TCP, NamedPipes, MSMQ.

4. How we can achieve Operation Overloading while exposing WCF Services?
By default, WSDL doesn’t support operation overloading. Overloading behavior can be achieved by using "Name" property of OperationContract attribute.
Collapse | Copy Code

[ServiceContract]
interface IMyCalculator
{
   [OperationContract(Name = "SumInt")]
   int Sum(int arg1,int arg2);

   [OperationContract(Name = "SumDouble")]
   double Sum(double arg1,double arg2);
}

When the proxy will be generated for these operations, it will have 2 methods with different names i.e. SumInt and SumDouble.


5. What Message Exchange Patterns (MEPs) supported by WCF? Explain each of them briefly.
1. Request/Response 2. One Way 3. Duplex
Request/Response

It’s the default pattern. In this pattern, a response message will always be generated to consumer when the operation is called, even with the void return type. In this scenario, response will have empty SOAP body.
One Way

In some cases, we are interested to send a message to service in order to execute certain business functionality but not interested in receiving anything back. OneWay MEP will work in such scenarios. If we want queued message delivery, OneWay is the only available option.
Duplex

The Duplex MEP is basically a two-way message channel. In some cases, we want to send a message to service to initiate some longer-running processing and require a notification back from service in order to confirm that the requested process has been completed.
 

6. What is DataContractSerializer and How its different from XmlSerializer?
Serialization is the process of converting an object instance to a portable and transferable format. So, whenever we are talking about web services, serialization is very important.

Windows Communication Foundation has DataContractSerializer that is new in .NET 3.0 and uses opt-in approach as compared to XmlSerializer that uses opt-out. Opt-in means specify whatever we want to serialize while Opt-out means you don’t have to specify each and every property to serialize, specify only those you don’t want to serialize. DataContractSerializer is about 10% faster than XmlSerializer but it has almost no control over how the object will be serialized. If we wanted to have more control over how object should be serialized that XmlSerializer is a better choice.
 

7. How we can use MessageContract partially with DataContract for a service operation in WCF?

MessageContract must be used all or none. If we are using MessageContract into an operation signature, then we must use MessageContract as the only parameter type and as the return type of the operation.


8. Which standard binding could be used for a service that was designed to replace an existing ASMX web service?The basicHttpBinding standard binding is designed to expose a service as if it is an ASMX/ASP.NET web service. This will enable us to support existing clients as applications are upgrade to WCF.


9. Please explain briefly different Instance Modes in WCF?
WCF will bind an incoming message request to a particular service instance, so the available modes are:

    Per Call: instance created for each call, most efficient in term of memory but need to maintain session.
    Per Session: Instance created for a complete session of a user. Session is maintained.
    Single: Only one instance created for all clients/users and shared among all.Least efficient in terms of memory.

10. Please explain different modes of security in WCF? Or Explain the difference between Transport and Message Level Security.

In Windows Communication Foundation, we can configure to use security at different levels

a. Transport Level security means providing security at the transport layer itself. When dealing with security at Transport level, we are concerned about integrity, privacy and authentication of message as it travels along the physical wire. It depends on the binding being used that how WCF makes it secure because most of the bindings have built-in security.
Collapse | Copy Code

            <netTcpBinding>
            <binding name="netTcpTransportBinding">
               <security mode="Transport">
                          <Transport clientCredentialType="Windows" />
               </security>
            </binding>
            </netTcpBinding>

b. Message Level Security For Tranport level security, we actually ensure the transport that is being used should be secured but in message level security, we actually secure the message. We encrypt the message before transporting it.
Collapse | Copy Code

             <wsHttpBinding>
             <binding name="wsHttpMessageBinding">
               <security mode="Message">
                           <Message clientCredentialType="UserName" />
               </security>
              </binding>
             </wsHttpBinding>

It totally depends upon the requirements but we can use a mixed security mode also as follows:
Collapse | Copy Code

             <basicHttpBinding>
             <binding name="basicHttp">
               <security mode="TransportWithMessageCredential">
                          <Transport />
                               <Message clientCredentialType="UserName" />
               </security>
             </binding>
             </basicHttpBinding>




What is the difference between WCF fault exceptions and normal .NET exceptions?
 If you throw a normal .NET exception from a WCF service as shown in the below code snippet.
If you throw a normal .NET exception from a WCF service as shown in the below code snippet.

               throw  new Exception("Divide by zero"); 

Your WCF client will get a very generic error with a message as shown in the below figure. Now this kind of message can be very confusing as it does not pinpoint what exactly the error is.


"The server is unable to precess the request etc...."

If you use a raise a fault exception as shown in the below code, your WCF clients will see the complete clear error rather than a generic error as shown previously.

throw  new FaultException("Divide by zero");



Your WCF client will now see a better error description as shown below.

  "Devide by zero Press any key to continue.."


 What is address in WCF and how many types of transport schemas are there in WCF?

Address is a way of letting client know that where a service is located. In WCF, every service is associated with a unique address. This contains the location of the service and transport schemas.

WCF supports following transport schemas

HTTP
TCP
Peer network
IPC (Inter-Process Communication over named pipes)
MSMQ

The sample address for above transport schema may look like

http://localhost:81
http://localhost:81/MyService
net.tcp://localhost:82/MyService
net.pipe://localhost/MyPipeService
net.msmq://localhost/private/MyMsMqService
net.msmq://localhost/MyMsMqService



What are contracts in WCF?
In WCF, all services expose contracts. The contract is a platform-neutral and standard way of describing what the service does.

WCF defines four types of contracts.
Service contracts

Describe which operations the client can perform on the service.
There are two types of Service Contracts.
ServiceContract - This attribute is used to define the Interface.
OperationContract - This attribute is used to define the method inside Interface.

[ServiceContract]

interface IMyContract

{

   [OperationContract]

   string MyMethod( );

}

class MyService : IMyContract

{

   public string MyMethod( )

   {

      return "Hello World";

   }

}

Data contracts

Define which data types are passed to and from the service. WCF defines implicit contracts for built-in types such as int and string, but we can easily define explicit opt-in data contracts for custom types.

There are two types of Data Contracts.
DataContract - attribute used to define the class
DataMember - attribute used to define the properties.

[DataContract]

class Contact

{

   [DataMember]

   public string FirstName;



   [DataMember]

   public string LastName;

}



If DataMember attributes are not specified for a properties in the class, that property can't be passed to-from web service.

Fault contracts

Define which errors are raised by the service, and how the service handles and propagates errors to its clients.


Message contracts

Allow the service to interact directly with messages. Message contracts can be typed or untyped, and are useful in interoperability cases and when there is an existing message format we have to comply with.

  Where we can host WCF services?

Every WCF services must be hosted somewhere. There are three ways of hosting WCF services.

They are

1. IIS
2. Self Hosting
3. WAS (Windows Activation Service)

What is binding and how many types of bindings are there in WCF?
A binding defines how an endpoint communicates to the world. A binding defines the transport (such as HTTP or TCP) and the encoding being used (such as text or binary). A binding can contain binding elements that specify details like the security mechanisms used to secure messages, or the message pattern used by an endpoint.

WCF supports nine types of bindings.

Basic binding

Offered by the BasicHttpBinding class, this is designed to expose a WCF service as a legacy ASMX web service, so that old clients can work with new services. When used by the client, this binding enables new WCF clients to work with old ASMX services.

TCP binding
Offered by the NetTcpBinding class, this uses TCP for cross-machine communication on the intranet. It supports a variety of features, including reliability, transactions, and security, and is optimized for WCF-to-WCF communication. As a result, it requires both the client and the service to use WCF.

Peer network binding
Offered by the NetPeerTcpBinding class, this uses peer networking as a transport. The peer network-enabled client and services all subscribe to the same grid and broadcast messages to it.

IPC binding
Offered by the NetNamedPipeBinding class, this uses named pipes as a transport for same-machine communication. It is the most secure binding since it cannot accept calls from outside the machine and it supports a variety of features similar to the TCP binding.

Web Service (WS) binding
Offered by the WSHttpBinding class, this uses HTTP or HTTPS for transport, and is designed to offer a variety of features such as reliability, transactions, and security over the Internet.

Federated WS binding
Offered by the WSFederationHttpBinding class, this is a specialization of the WS binding, offering support for federated security.

Duplex WS binding
Offered by the WSDualHttpBinding class, this is similar to the WS binding except it also supports bidirectional communication from the service to the client.

MSMQ binding
Offered by the NetMsmqBinding class, this uses MSMQ for transport and is designed to offer support for disconnected queued calls.

MSMQ integration binding
Offered by the MsmqIntegrationBinding class, this converts WCF messages to and from MSMQ messages, and is designed to interoperate with legacy MSMQ clients. 


What is endpoint in WCF?
Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service. In WCF the relationship between Address, Contract and Binding is called Endpoint.

The Endpoint is the fusion of Address, Contract and Binding.