Web Application SEO

November 26, 2012

Developers sometimes make technical decisions about Web applications that have a negative impact on the applications’ search engine rankings. For Web applications such as shopping carts, a hit to search engine optimization (SEO) can be deadly to the revenue stream. Here are five tips to help you make sure that your Web applications are search engine friendly.

1: Specify the canonical URL for a page

Search engines do not like it when there are multiple URLs to get to the same or similar content; search engines end up treating each URL as a separate page and splitting its “weight,” which pushes each perceived duplicate down in the rankings. We see this a lot in shopping carts, where various guided searches, filtering, and sorting can lead the engine to similar content.

Fortunately, Google introduced a system so that pages can specify what the “canonical” URL is for a page. Use this system to ensure that the search engines know what single URL to look at for any given piece of content.

2: Display critical text in a normal fashion

Have you ever wondered why a search can lead to a page that has nothing to do with what you searched for? Over the years, spammers have found all sorts of ways to bury content from normal view but make it visible to search engines. The search engines have caught on, and that is why this kind of spam is much less of a problem now.

A side effect of the war on spam is that search engines ignore text that a normal viewer does not see, and text that does not appear without JavaScript is often ignored as well. As a result, you need to be cautious about the use of AJAX and CSS tricks. If the text is potentially invisible, there is a good chance that the search engines will ignore it, even if their JavaScript processing reveals it. You should make sure that critical text is displayed in a normal fashion.

3: Code for disabled users

All developers know they should be making their Web applications work well for disabled users, right? Well, it turns out that search engines like many of the same things that make a site or an application accessible to the disabled as well. Things like descriptive link text, alt text for images, and more, all help your search engine rankings too.

4: Use better titles and descriptions

It’s simple to make Web applications use a generic title and description for all pages, especially if they are using some sort of template. However, it’s just as easy to have the applications insert a unique value in there from the configuration or the database. Search engines will like your content a lot more when each page has unique title and description fields (combine this with the canonical links from tip #1), so make sure that your application puts them in. For example, use the product’s name as a title on a shopping site.

5. Write quality HTML

Too many times, a great site’s SEO suffers due to bad HTML. In my opinion, the biggest culprit is ASP.NET WebForms, which takes too much control out of the developer’s hands and fills pages up with all sorts of junk to work its magic. If possible, switch to a system such as ASP.NET MVC, Ruby on Rails, or PHP to get the most control and least amount of garbage in your HTML. Getting your HTML under control will also reduce page load times from the decreased download size, and reduce difficulty in parsing and rendering it.

Summary

This is not the be-all and end-all of the relationship between Web applications and search engines, but following these tips will go a long way towards helping your applications be as visible as possible to users. Even better, most of these tips will also make using your application a better experience.

Happy Developing Guys.. Will update you more on this !!

0

Comparing Two DataTables in C#

November 2, 2012

Comparing two DataTable and get the final table with difference in it, this kind of requirement is generally arise generally when we are doing multiple insert or update. I have scenario like get the two different tables data, compare it and if there is difference in output then insert that data into the third table. So use the approach to get the data from database into different table and then insert the difference output using SqlBulkCopy in to the third table.

 

Code:

Following is the code to compare two datatable. Just copy and paste this class into your code and its working.

 

using System;

using System.Data;

 

namespace CompareDataTable

{

public class CompareDataTables

{

public static DataTable CompareTables(DataTable first, DataTable second)

{

first.TableName = “FirstTable”;

second.TableName = “SecondTable”;

 

//Create Empty Table

DataTable table = new DataTable(“Difference”);

try

{

//Must use a Dataset to make use of a DataRelation object

using (DataSet ds = new DataSet())

{

//Add tables

ds.Tables.AddRange(new DataTable[] { first.Copy(), second.Copy() });

//Get Columns for DataRelation

//DataColumn[] firstcolumns = new DataColumn[ds.Tables[0].Columns.Count];

DataColumn[] firstcolumns = new DataColumn[2];

firstcolumns[0] = ds.Tables[0].Columns[1];

firstcolumns[1] = ds.Tables[0].Columns[7];

//for (int i = 0; i < firstcolumns.Length; i++)

//{

// firstcolumns[i] = ds.Tables[0].Columns[i];

//}

 

//DataColumn[] secondcolumns = new DataColumn[ds.Tables[1].Columns.Count];

DataColumn[] secondcolumns = new DataColumn[2];

secondcolumns[0] = ds.Tables[1].Columns[1];

secondcolumns[1] = ds.Tables[1].Columns[7];

//for (int i = 0; i < secondcolumns.Length; i++)

//{

// secondcolumns[i] = ds.Tables[1].Columns[i];

//}

 

//Create DataRelation

DataRelation r = new DataRelation(string.Empty, firstcolumns, secondcolumns, false);

 

ds.Relations.Add(r);

//Create columns for return table

for (int i = 0; i < first.Columns.Count; i++)

{

table.Columns.Add(first.Columns[i].ColumnName, first.Columns[i].DataType);

}

//If First Row not in Second, Add to return table.

table.BeginLoadData();

 

foreach (DataRow parentrow in ds.Tables[0].Rows)

{

DataRow[] childrows = parentrow.GetChildRows(r);

if (childrows == null || childrows.Length == 0)

table.LoadDataRow(parentrow.ItemArray, true);

}

table.EndLoadData();

}

}

catch (Exception ex)

{

throw ex;

}

return table;

}

}

}

Code Explanation:

 

  1. CompareTables method is static, so you can call it directly from your class. Just add the appropriate reference.
  2. Pass the two data tables in this method.
  3. Then creates the dataset.
  4. Add two tables into the dataset.
  5. Then important part, define the columns two compare the data table. In my case i just want to check the column 1 & 7. If there is a mismatch between this two then inserts the record. You can modify the code as per your requirement or just uncomment the line above and below my code , which adds all columns.
  6. Creates data relation on that column(s).
  7. Add relation two the dataset.
  8. Create the target or difference table colums
  9. Then load the difference data in it and return the difference table.

Happy Coding !!

0

Delete Duplicate Rows from DataTable

October 29, 2012

This post explains how to Remove/Delete Duplicate Rows Records From Datatable using C# or VB.NET in Asp.Net.

Remove Duplicate Rows Records from datatable

My table in database contains duplicate records as shown in image and I want to remove those duplicate records temporarily before displaying them in gridview.

For this purpose I’m filling records in DataTable and deleting duplicates.

I have placed one gridview on the page and populating it from DataTable in Page_Load event in code behind.

There are two ways to remove duplicates from datatable.

Method 1: 

In this method we create a DataView on DataTable and pass the column names to check for duplicates as array in ToTable method of DataView.

C# CODE
        DataView dView = new DataView(dtRemoveDuplicate);
        string[] arrColumns = { "Id", "Name", "Location" };
        dtRemoveDuplicate = dView.ToTable(true, arrColumns);
VB.NET CODE
        Dim dView As New DataView(dtRemoveDuplicate)
        Dim arrColumns As String() = {"Id", "Name", "Location"}
        dtRemoveDuplicate = dView.ToTable(True, arrColumns)

Method 2 : 

Create a method which takes datatable and column name to look for duplicates as parameterand returns DataTable after removing duplicate records.

 

C# CODE
protected void Page_Load(object sender, EventArgs e)
    {
        string strConnection = 
        ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
        SqlConnection con = new SqlConnection();
        con.ConnectionString = strConnection;
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "SELECT * FROM Details";
        cmd.Connection = con;
        SqlDataAdapter dAdapter = new SqlDataAdapter(cmd);
        DataTable dtRemoveDuplicate = new DataTable();
        dAdapter.Fill(dtRemoveDuplicate);
        dtRemoveDuplicate = 
        DeleteDuplicateFromDataTable(dtRemoveDuplicate, "Id");
        GridView1.DataSource = dtRemoveDuplicate;
        GridView1.DataBind();
    }
protected DataTable DeleteDuplicateFromDataTable(DataTable dtDuplicate, 
                                                      string columnName)
    {
        Hashtable hashT = new Hashtable();
        ArrayList arrDuplicate = new ArrayList();
        foreach (DataRow row in dtDuplicate.Rows)
        {
            if (hashT.Contains(row[columnName]))
                arrDuplicate.Add(row);
            else
                hashT.Add(row[columnName], string.Empty);
        }
        foreach (DataRow row in arrDuplicate)
            dtDuplicate.Rows.Remove(row);

        return dtDuplicate;
    }
VB.NET CODE
Protected Sub Page_Load(sender As Object, e As EventArgs)
 Dim strConnection As String = 
 ConfigurationManager.ConnectionStrings("ConString").ConnectionString
 Dim con As New SqlConnection()
 con.ConnectionString = strConnection
 Dim cmd As New SqlCommand()
 cmd.CommandType = CommandType.Text
 cmd.CommandText = "SELECT * FROM Details"
 cmd.Connection = con
 Dim dAdapter As New SqlDataAdapter(cmd)
 Dim dtRemoveDuplicate As New DataTable()
 dAdapter.Fill(dtRemoveDuplicate)
 dtRemoveDuplicate = DeleteDuplicateFromDataTable(dtRemoveDuplicate, "Id")
 GridView1.DataSource = dtRemoveDuplicate
 GridView1.DataBind()
End Sub
Protected Function DeleteDuplicateFromDataTable(dtDuplicate As DataTable, 
                                       columnName As String) As DataTable
 Dim hashT As New Hashtable()
 Dim arrDuplicate As New ArrayList()
 For Each row As DataRow In dtDuplicate.Rows
  If hashT.Contains(row(columnName)) Then
   arrDuplicate.Add(row)
  Else
   hashT.Add(row(columnName), String.Empty)
  End If
 Next
 For Each row As DataRow In arrDuplicate
  dtDuplicate.Rows.Remove(row)
 Next

 Return dtDuplicate
End Function
Delete Duplicate Records from datatable
And result will be as shown in the image. All duplicate records have been removed from DataTable.

Happy Coding !!

0

WCF Configuration from Novice to Ninja Series Part 2

October 14, 2012

In today’s blog I am going to explain basicHttpContextBinding. The configuration for basicHttpContextBinding looks like below. If we observe the Configuration of basicHttpBinding and basicHttpContextBinding the configuration is absolutely same. BasicHttpBinding defines a binding used by WCF to configure and expose endpoints which provide compatibility with ASMX based services and clients, or to any other type of services which comply with WS-I Basic Profile 1.1. It makes use of HTTP transport protocol to deliver SOAP 1.1 messages. BasicHttpContextBinding provides same functionality as BasicHttpBinding but with some extras. It ensures that the WCF service exposed through this endpoint biding is compatible with ASP.NET session state features.

<basicHttpContextBinding>
<!-- Binding Section Starting Point -->
<binding
allowCookies="Boolean"
bypassProxyOnLocal="Boolean"
closeTimeout="TimeSpan"
envelopeVersion="None/Soap11/Soap12"
hostNameComparisonMode="StrongWildCard/Exact/WeakWildcard"
maxBufferPoolSize="Integer"
maxBufferSize="Integer"
maxReceivedMessageSize="Integer"
messageEncoding="Text/Mtom"
name="string"
openTimeout="TimeSpan"
proxyAddress="URI"
receiveTimeout="TimeSpan"
sendTimeout="TimeSpan"
textEncoding="UnicodeFffeTextEncoding/Utf16TextEncoding/Utf8TextEncoding"
transferMode="Buffered/Streamed/StreamedRequest/StreamedResponse"
useDefaultWebProxy="Boolean">

<!-- Security Section Starting Point -->
<security mode="None/Transport/Message/TransportWithMessageCredential
/TransportCredentialOnly">

<!-- Transport Section Starting Point -->

<transport clientCredentialType="None/Basic/Digest
/Ntlm/Windows/Certificate"
proxyCredentialType="None/Basic/Digest/Ntlm/Windows"
realm="string" />
<!-- Transport Section Ending Point -->

<!-- Message Section Starting Point -->
<message algorithmSuite="Basic128/Basic192/Basic256/Basic128Rsa15
/Basic256Rsa15/TripleDes/TripleDesRsa15/Basic128Sha256
/Basic192Sha256/TripleDesSha256/Basic128Sha256Rsa15
/Basic192Sha256Rsa15/Basic256Sha256Rsa15/TripleDesSha256Rsa15"
clientCredentialType="UserName/Certificate"/>
<!-- Message Section Ending Point -->

</security>
<!-- Security Section Ending Point -->

<!—Reader Quotas Section Starting Point -->
<readerQuotas maxArrayLength="Integer"
maxBytesPerRead="Integer"
maxDepth="Integer"
maxNameTableCharCount="Integer"
maxStringContentLength="Integer" />
<!—Reader Quotas Section Ending Point -->
</binding>
<!-- Binding Section Ending Point -->
</basicHttpContextBinding>

Binding Attributes

allowCookies
A Boolean value that indicates whether the client accepts cookies and propagates them on future requests or not. The default is false. You can use this property when you interact with ASMX Web services that use cookies. In this way, you can be sure that the cookies returned from the server are automatically copied to all future client requests for that service.

bypassProxyOnLocal
A Boolean value that indicates whether to bypass the proxy server for local addresses. The default is false. An Internet resource is local if it has a local address. A local address is one that is on same computer, the local LAN or intranet and is identified, syntactically, by the lack of a period (.) as in the URIs “http://webserver/” and “http://localhost/”. Setting this attribute determines whether endpoints configured with the BasicHttpBinding use the proxy server when accessing local resources. If this attribute is true, requests to local Internet resources do not use the proxy server. Use the host name (rather than localhost) if you want clients to go through a proxy when talking to services on the same machine when this attribute is set to true. When this attribute is false, all Internet requests are made through the proxy server.

closeTimeout
A TimeSpan value that specifies the interval of time provided for a close operation to complete. This value should be greater than or equal to Zero. The default is 00:01:00

envelopeVersion
Specifies the version of SOAP that is used for messages that are processed by this binding. The only valid value is Soap11.

hostnameComparisonMode
Specifies the HTTP hostname comparison mode used to parse URIs. This attribute is of type HostnameComparisonMode, which indicates whether the hostname is used to reach the service when matching on the URI. The default value is StrongWildcard, which ignores the hostname in the match.

maxBufferPoolSize
An integer value that specifies the maximum amount of memory that is allocated for use by the manager of the message buffers that receive messages from the channel. The default value is 524288 (0x80000) bytes. The Buffer Manager minimizes the cost of using buffers by using a buffer pool. Buffers are required to process messages by the service when they come out of the channel. If there is not sufficient memory in the buffer pool to process the message load, the Buffer Manager must allocate additional memory from the CLR heap, which increases the garbage collection overhead. Extensive allocation from the CLR garbage heap is an indication that the buffer pool size is too small and that performance can be improved with a larger allocation by increasing the limit specified by this attribute.

maxBufferSize
An integer value that specifies the maximum size, in bytes, of a buffer that stores messages while they are processed for an endpoint configured with this binding. The default value is 65,536 bytes.

maxReceivedMessageSize
A positive integer that defines the maximum message size, in bytes, including headers, for a message that can be received on a channel configured with this binding. The sender receives a SOAP fault if the message is too large for the receiver. The receiver drops the message and creates an entry of the event in the trace log. The default is 65,536 bytes.

messageEncoding
Defines the encoder used to encode the SOAP message. Valid values include the following:
Text: Use a text message encoder.
Mtom: Use a Message Transmission Organization Mechanism 1.0 (MTOM) encoder.

The default is Text. This attribute is of type WSMessageEncoding.

name

A string that contains the configuration name of the binding. This value should be unique because it is used as identification for the binding. Each binding has a name and namespace attribute that together uniquely identify it in the metadata of the service. In addition, this name is unique among bindings of the same type. Starting with .NET Framework 4, bindings and behaviors are not required to have a name.

namespace

Specifies the XML namespace of the binding. The default value is “http://tempuri.org/Bindings”. Each binding has a name and namespace attribute that together uniquely identify it in the metadata of the service.

openTimeout

A TimeSpan value that specifies the interval of time provided for an open operation to complete. This value should be greater than or equal to Zero. The default is 00:01:00

proxyAddress

A URI that contains the address of the HTTP proxy. If useSystemWebProxy is set to true, this setting must be null. The default is null.

receiveTimeout

A TimeSpan value that specifies the interval of time provided for a receive operation to complete. This value should be greater than or equal to Zero. The default is 00:10:00

sendTimeout

A TimeSpan value that specifies the interval of time provided for a send operation to complete. This value should be greater than or equal to Zero. The default is 00:01:00

textEncoding

Sets the character set encoding to be used for emitting messages on the binding. Valid values include the following:
BigEndianUnicode: Unicode BigEndian encoding.
Unicode: 16-bit encoding.
UTF8: 8-bit encoding

The default is UTF8. This attribute is of type Encoding.

transferMode

A valid TransferMode value that specifies whether messages are buffered or streamed on a request or response.

useDefaultWebProxy

A Boolean value that specifies whether the auto-configured HTTP proxy of the system should be used, if available. The default is true.

Security Attributes

mode

Mode is Optional and it specifies the type of security that is going to be used. The default value is None and the possible values are mentioned below.

None: If we mention the mode as none messages are not secured during transfer.

Transport: Security is provided using HTTPS transport. The SOAP messages are secured using HTTPS. The service is authenticated to the client using the service’s X.509 certificate. The client is authenticated using the ClientCredentialType supplied.

Message: Security is provided using SOAP message security. By default, the body is encrypted and signed. For this binding, the system requires that the server certificate be provided to the client out of band. The only valid ClientCredentialType for this binding is Certificate.

TransportWithMessageCredential: Integrity, confidentiality and server authentication are provided by transport security. Client authentication is provided by means of SOAP message security. This mode is relevant when the user is authenticating using username/password and there is an existing HTTP deployment for securing message transfer.

TransportCredentialOnly: This mode does not provide message integrity and confidentiality. It provides http-based client authentication. This mode should be used with caution. It should be used in environments where the transport security is being provided by other means (such as IPSec) and only client authentication is provided by the WCF infrastructure.

Security Child Elements

Transport and Message are the Child elements for the Security

transport

clientCredentialType

Specifies the type of credential to be used when performing client authentication using HTTP authentication. The default is None. This attribute is of type HttpClientCredentialType.

Possible Values
None: Messages are not secured during transfer.
Basic: Specifies basic authentication.
Digest: Specifies digest authentication.
Ntlm: Specifies NTLM authentication when possible, and if Windows authentication fails.
Windows: Specifies Windows integrated authentication.

 

proxyCredentialType

Specifies the type of credential to be used when performing client authentication from within a domain using a proxy over HTTP. This attribute is applicable only when the mode attribute of the parent security element is Transport or TransportCredentialsOnly. This attribute is of type HttpProxyCredentialType.

Possible Values
None: Messages are not secured during transfer.
Basic: Specifies basic authentication as defined by RFC 2617 – HTTP Authentication: Basic and Digest Authentication.
Digest: Specifies digest authentication as defined by RFC 2617 – HTTP Authentication: Basic and Digest Authentication.
Ntlm: Specifies NTLM authentication when possible, and if Windows authentication fails.
Windows: Specifies Windows integrated authentication.
Certificate: Performs client authentication using a certificate. This option works only if the Mode attribute of the parent security element is set to Transport, and will not work if it is set to TransportCredentialOnly.

 

realm

A string that specifies the realm that is used by the HTTP authentication scheme for digest or basic authentication. The default is an empty string.

policyEnforcement

This enumeration specifies when the ExtendedProtectionPolicy should be enforced.

Possible Values
Never: The policy is never enforced (Extended Protection is disabled).
WhenSupported: The policy is enforced only if the client supports Extended Protection.
Always: The policy is always enforced. Clients which don’t support Extended Protection will fail to authenticate.

protectionScenario

This enumeration specifies the protection scenario enforced by the policy.

message

algorithmSuite

Sets the message encryption and key-wrap algorithms. This attribute is of type SecurityAlgorithmSuite, which specifies the algorithms and the key sizes. These algorithms map to those specified in the Security Policy Language (WS-SecurityPolicy) specification.

Possible Values:
Basic128: Gets the Basic128 algorithm suite.

Basic128Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm and 128-bit Basic as the message encryption algorithm.

Basic128Sha256: Gets an algorithm suite that uses SHA256 for the signature digest and 128-bit Basic as the message encryption algorithm.

Basic128Sha256Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm, SHA256 for the signature digest, and 128-bit Basic as the message encryption algorithm.

Basic192: Gets an algorithm suite that uses 192-bit Basic as the message encryption algorithm.

Basic192Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm and 192-bit Basic as the message encryption algorithm.

Basic192Sha256: Gets an algorithm suite which uses SHA256 for the signature digest and 192-bit Basic as the message encryption algorithm.

Basic192Sha256Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm, SHA256 for the signature digest, and 192-bit Basic as the message encryption algorithm.

Basic256: Gets an algorithm suite that uses 256-bit Basic as the message encryption algorithm.

Basic256Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm and 256-bit Basic as the message encryption algorithm.

Basic256Sha256: Gets an algorithm suite that uses SHA256 for the signature digest and 256-bit Basic as the message encryption algorithm.

Basic256Sha256Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm, SHA256 for the signature digest, and 128-bit Basic as the message encryption algorithm.

Default: Gets the default algorithm suite.

TripleDes: Gets the Triple Data Encryption Standard (DES) algorithm suite.

TripleDesRsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm and 192-bit Triple Data Encryption Standard (DES) as the message encryption algorithm.

TripleDesSha256: Gets an algorithm suite that uses SHA256 for the signature digest and 192-bit Triple Data Encryption Standard (DES) as the message encryption algorithm.

TripleDesSha256Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm, SHA256 for the signature digest, and 192-bit Triple Data Encryption Standard (DES) as the message encryption algorithm.

The default value is Basic256.

clientCredentialType

Specifies the type of credential to be used when performing client authentication using message-based security. The default is UserName.
Possible Values
UserName: Requires the client be authenticated to the server with a UserName credential. This credential needs to be specified using the <clientCredentials>. WCF does not support sending a password digest or deriving keys using passwords and using such keys for message security. Therefore, WCF enforces that the transport be secured when using UserName credentials. For the basicHttpBinding, this requires setting up an SSL channel.

Certificate: Requires that the client be authenticated to the server using a certificate. The client credential in this case needs to be specified using <clientCredentials> and the <clientCertificate> of <serviceCredentials>. In addition, when using message security mode, the client needs to be provisioned with the service certificate. The service credential in this case needs to be specified using ClientCredentials class or ClientCredentials behavior element and specifying the service certificate using the <serviceCertificate> of <serviceCredentials>.

readerQuotas

maxArrayLength

A positive integer that specifies the maximum allowed array length of data being received by Windows Communication Foundation (WCF) from a client. The default is 16384.

maxBytesPerRead

A positive integer that specifies the maximum allowed bytes returned per read. The default is 4096.

maxDepth

A positive integer that specifies the maximum nested node depth per read. The default is 32.

maxNameTableCharCount

A positive integer that specifies the maximum characters allowed in a table name. The default is 16384.

maxStringContentLength

A positive integer that specifies the maximum characters allowed in XML element content. The default is 8192.

0

WCF Configuration from Novice to Ninja Series Part 1

September 27, 2012

I had observed hard time for developers in playing with the WCF Configurations. So I had decided to provide the WCF Configurations in detail for each kind of Bindings. In this article I would like to cover basicHttpBinding Configuration settings.

<basicHttpBinding>
<!-- Binding Section Starting Point -->
<binding
allowCookies="Boolean"
bypassProxyOnLocal="Boolean"
closeTimeout="TimeSpan"
envelopeVersion="None/Soap11/Soap12"
hostNameComparisonMode="StrongWildCard/Exact/WeakWildcard"
maxBufferPoolSize="Integer"
maxBufferSize="Integer"
maxReceivedMessageSize="Integer"
messageEncoding="Text/Mtom"
name="string"
openTimeout="TimeSpan"
proxyAddress="URI"
receiveTimeout="TimeSpan"
sendTimeout="TimeSpan"
textEncoding="UnicodeFffeTextEncoding/Utf16TextEncoding/Utf8TextEncoding"
transferMode="Buffered/Streamed/StreamedRequest/StreamedResponse"
useDefaultWebProxy="Boolean">

<!-- Security Section Starting Point -->
<security mode="None/Transport/Message/TransportWithMessageCredential
/TransportCredentialOnly">

<!-- Transport Section Starting Point -->

<transport clientCredentialType="None/Basic/Digest
/Ntlm/Windows/Certificate"
proxyCredentialType="None/Basic/Digest/Ntlm/Windows"
realm="string" />
<!-- Transport Section Ending Point -->

<!-- Message Section Starting Point -->
<message algorithmSuite="Basic128/Basic192/Basic256/Basic128Rsa15
/Basic256Rsa15/TripleDes/TripleDesRsa15/Basic128Sha256
/Basic192Sha256/TripleDesSha256/Basic128Sha256Rsa15
/Basic192Sha256Rsa15/Basic256Sha256Rsa15/TripleDesSha256Rsa15"
clientCredentialType="UserName/Certificate"/>
<!-- Message Section Ending Point -->

</security>
<!-- Security Section Ending Point -->

<!—Reader Quotas Section Starting Point -->
<readerQuotas maxArrayLength="Integer"
maxBytesPerRead="Integer"
maxDepth="Integer"
maxNameTableCharCount="Integer"
maxStringContentLength="Integer" />
<!—Reader Quotas Section Ending Point -->
</binding>
<!-- Binding Section Ending Point -->
</basicHttpBinding>

Binding Attributes

allowCookies
A Boolean value that indicates whether the client accepts cookies and propagates them on future requests or not. The default is false. You can use this property when you interact with ASMX Web services that use cookies. In this way, you can be sure that the cookies returned from the server are automatically copied to all future client requests for that service.

bypassProxyOnLocal
A Boolean value that indicates whether to bypass the proxy server for local addresses. The default is false. An Internet resource is local if it has a local address. A local address is one that is on same computer, the local LAN or intranet and is identified, syntactically, by the lack of a period (.) as in the URIs “http://webserver/” and “http://localhost/”. Setting this attribute determines whether endpoints configured with the BasicHttpBinding use the proxy server when accessing local resources. If this attribute is true, requests to local Internet resources do not use the proxy server. Use the host name (rather than localhost) if you want clients to go through a proxy when talking to services on the same machine when this attribute is set to true. When this attribute is false, all Internet requests are made through the proxy server.

closeTimeout
A TimeSpan value that specifies the interval of time provided for a close operation to complete. This value should be greater than or equal to Zero. The default is 00:01:00

envelopeVersion
Specifies the version of SOAP that is used for messages that are processed by this binding. The only valid value is Soap11.

hostnameComparisonMode
Specifies the HTTP hostname comparison mode used to parse URIs. This attribute is of type HostnameComparisonMode, which indicates whether the hostname is used to reach the service when matching on the URI. The default value is StrongWildcard, which ignores the hostname in the match.

maxBufferPoolSize
An integer value that specifies the maximum amount of memory that is allocated for use by the manager of the message buffers that receive messages from the channel. The default value is 524288 (0x80000) bytes. The Buffer Manager minimizes the cost of using buffers by using a buffer pool. Buffers are required to process messages by the service when they come out of the channel. If there is not sufficient memory in the buffer pool to process the message load, the Buffer Manager must allocate additional memory from the CLR heap, which increases the garbage collection overhead. Extensive allocation from the CLR garbage heap is an indication that the buffer pool size is too small and that performance can be improved with a larger allocation by increasing the limit specified by this attribute.

maxBufferSize
An integer value that specifies the maximum size, in bytes, of a buffer that stores messages while they are processed for an endpoint configured with this binding. The default value is 65,536 bytes.

maxReceivedMessageSize
A positive integer that defines the maximum message size, in bytes, including headers, for a message that can be received on a channel configured with this binding. The sender receives a SOAP fault if the message is too large for the receiver. The receiver drops the message and creates an entry of the event in the trace log. The default is 65,536 bytes.

messageEncoding
Defines the encoder used to encode the SOAP message. Valid values include the following:
Text: Use a text message encoder.
Mtom: Use a Message Transmission Organization Mechanism 1.0 (MTOM) encoder.

The default is Text. This attribute is of type WSMessageEncoding.

name

A string that contains the configuration name of the binding. This value should be unique because it is used as identification for the binding. Each binding has a name and namespace attribute that together uniquely identify it in the metadata of the service. In addition, this name is unique among bindings of the same type. Starting with .NET Framework 4, bindings and behaviors are not required to have a name.

namespace

Specifies the XML namespace of the binding. The default value is “http://tempuri.org/Bindings”. Each binding has a name and namespace attribute that together uniquely identify it in the metadata of the service.

openTimeout

A TimeSpan value that specifies the interval of time provided for an open operation to complete. This value should be greater than or equal to Zero. The default is 00:01:00

proxyAddress

A URI that contains the address of the HTTP proxy. If useSystemWebProxy is set to true, this setting must be null. The default is null.

receiveTimeout

A TimeSpan value that specifies the interval of time provided for a receive operation to complete. This value should be greater than or equal to Zero. The default is 00:10:00

sendTimeout

A TimeSpan value that specifies the interval of time provided for a send operation to complete. This value should be greater than or equal to Zero. The default is 00:01:00

textEncoding

Sets the character set encoding to be used for emitting messages on the binding. Valid values include the following:
BigEndianUnicode: Unicode BigEndian encoding.
Unicode: 16-bit encoding.
UTF8: 8-bit encoding

The default is UTF8. This attribute is of type Encoding.

transferMode

A valid TransferMode value that specifies whether messages are buffered or streamed on a request or response.

useDefaultWebProxy

A Boolean value that specifies whether the auto-configured HTTP proxy of the system should be used, if available. The default is true.

Security Attributes

mode

Mode is Optional and it specifies the type of security that is going to be used. The default value is None and the possible values are mentioned below.

None: If we mention the mode as none messages are not secured during transfer.

Transport: Security is provided using HTTPS transport. The SOAP messages are secured using HTTPS. The service is authenticated to the client using the service’s X.509 certificate. The client is authenticated using the ClientCredentialType supplied.

Message: Security is provided using SOAP message security. By default, the body is encrypted and signed. For this binding, the system requires that the server certificate be provided to the client out of band. The only valid ClientCredentialType for this binding is Certificate.

TransportWithMessageCredential: Integrity, confidentiality and server authentication are provided by transport security. Client authentication is provided by means of SOAP message security. This mode is relevant when the user is authenticating using username/password and there is an existing HTTP deployment for securing message transfer.

TransportCredentialOnly: This mode does not provide message integrity and confidentiality. It provides http-based client authentication. This mode should be used with caution. It should be used in environments where the transport security is being provided by other means (such as IPSec) and only client authentication is provided by the WCF infrastructure.

Security Child Elements

Transport and Message are the Child elements for the Security

transport

clientCredentialType

Specifies the type of credential to be used when performing client authentication using HTTP authentication. The default is None. This attribute is of type HttpClientCredentialType.

Possible Values
None: Messages are not secured during transfer.
Basic: Specifies basic authentication.
Digest: Specifies digest authentication.
Ntlm: Specifies NTLM authentication when possible, and if Windows authentication fails.
Windows: Specifies Windows integrated authentication.

 

proxyCredentialType

Specifies the type of credential to be used when performing client authentication from within a domain using a proxy over HTTP. This attribute is applicable only when the mode attribute of the parent security element is Transport or TransportCredentialsOnly. This attribute is of type HttpProxyCredentialType.

Possible Values
None: Messages are not secured during transfer.
Basic: Specifies basic authentication as defined by RFC 2617 – HTTP Authentication: Basic and Digest Authentication.
Digest: Specifies digest authentication as defined by RFC 2617 – HTTP Authentication: Basic and Digest Authentication.
Ntlm: Specifies NTLM authentication when possible, and if Windows authentication fails.
Windows: Specifies Windows integrated authentication.
Certificate: Performs client authentication using a certificate. This option works only if the Mode attribute of the parent security element is set to Transport, and will not work if it is set to TransportCredentialOnly.

 

realm

A string that specifies the realm that is used by the HTTP authentication scheme for digest or basic authentication. The default is an empty string.

policyEnforcement

This enumeration specifies when the ExtendedProtectionPolicy should be enforced.

Possible Values
Never: The policy is never enforced (Extended Protection is disabled).
WhenSupported: The policy is enforced only if the client supports Extended Protection.
Always: The policy is always enforced. Clients which don’t support Extended Protection will fail to authenticate.

protectionScenario

This enumeration specifies the protection scenario enforced by the policy.

message

algorithmSuite

Sets the message encryption and key-wrap algorithms. This attribute is of type SecurityAlgorithmSuite, which specifies the algorithms and the key sizes. These algorithms map to those specified in the Security Policy Language (WS-SecurityPolicy) specification.

Possible Values:
Basic128: Gets the Basic128 algorithm suite.

Basic128Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm and 128-bit Basic as the message encryption algorithm.

Basic128Sha256: Gets an algorithm suite that uses SHA256 for the signature digest and 128-bit Basic as the message encryption algorithm.

Basic128Sha256Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm, SHA256 for the signature digest, and 128-bit Basic as the message encryption algorithm.

Basic192: Gets an algorithm suite that uses 192-bit Basic as the message encryption algorithm.

Basic192Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm and 192-bit Basic as the message encryption algorithm.

Basic192Sha256: Gets an algorithm suite which uses SHA256 for the signature digest and 192-bit Basic as the message encryption algorithm.

Basic192Sha256Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm, SHA256 for the signature digest, and 192-bit Basic as the message encryption algorithm.

Basic256: Gets an algorithm suite that uses 256-bit Basic as the message encryption algorithm.

Basic256Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm and 256-bit Basic as the message encryption algorithm.

Basic256Sha256: Gets an algorithm suite that uses SHA256 for the signature digest and 256-bit Basic as the message encryption algorithm.

Basic256Sha256Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm, SHA256 for the signature digest, and 128-bit Basic as the message encryption algorithm.

Default: Gets the default algorithm suite.

TripleDes: Gets the Triple Data Encryption Standard (DES) algorithm suite.

TripleDesRsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm and 192-bit Triple Data Encryption Standard (DES) as the message encryption algorithm.

TripleDesSha256: Gets an algorithm suite that uses SHA256 for the signature digest and 192-bit Triple Data Encryption Standard (DES) as the message encryption algorithm.

TripleDesSha256Rsa15: Gets an algorithm suite that uses RSA15 as the key wrap algorithm, SHA256 for the signature digest, and 192-bit Triple Data Encryption Standard (DES) as the message encryption algorithm.

The default value is Basic256.

clientCredentialType

Specifies the type of credential to be used when performing client authentication using message-based security. The default is UserName.
Possible Values
UserName: Requires the client be authenticated to the server with a UserName credential. This credential needs to be specified using the <clientCredentials>. WCF does not support sending a password digest or deriving keys using passwords and using such keys for message security. Therefore, WCF enforces that the transport be secured when using UserName credentials. For the basicHttpBinding, this requires setting up an SSL channel.

Certificate: Requires that the client be authenticated to the server using a certificate. The client credential in this case needs to be specified using <clientCredentials> and the <clientCertificate> of <serviceCredentials>. In addition, when using message security mode, the client needs to be provisioned with the service certificate. The service credential in this case needs to be specified using ClientCredentials class or ClientCredentials behavior element and specifying the service certificate using the <serviceCertificate> of <serviceCredentials>.

readerQuotas

maxArrayLength

A positive integer that specifies the maximum allowed array length of data being received by Windows Communication Foundation (WCF) from a client. The default is 16384.

maxBytesPerRead

A positive integer that specifies the maximum allowed bytes returned per read. The default is 4096.

maxDepth

A positive integer that specifies the maximum nested node depth per read. The default is 32.

maxNameTableCharCount

A positive integer that specifies the maximum characters allowed in a table name. The default is 16384.

maxStringContentLength

A positive integer that specifies the maximum characters allowed in XML element content. The default is 8192.

0