July 2018 Tenants maintenance

by Admin 21. May 2014 11:09

 

Tags:

Web API & WCF comparision

by Admin 5. March 2014 13:18

WCF is Microsoft’s unified programming model for building service-oriented applications. It enables developers to build secure, reliable, transacted solutions that integrate across platforms and interoperate with existing investments. (ASP.NET Web APIis a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework. This topic presents some guidance to help you decide which technology will best meet your needs.

Choosing which technology to use

The following table describes the major features of each technology.

WCF

ASP.NET Web API

Enables building services that support multiple transport protocols (HTTP, TCP, UDP, and custom transports) and allows switching between them.

HTTP only. First-class programming model for HTTP. More suitable for access from various browsers, mobile devices etc enabling wide reach.

Enables building services that support multiple encodings (Text, MTOM, and Binary) of the same message type and allows switching between them.

Enables building Web APIs that support wide variety of media types including XML, JSON etc.

Supports building services with WS-* standards like Reliable Messaging, Transactions, Message Security.

Uses basic protocol and formats such as HTTP, WebSockets, SSL, JQuery, JSON, and XML. There is no support for higher level protocols such as Reliable Messaging or Transactions.

Supports Request-Reply, One Way, and Duplex message exchange patterns.

HTTP is request/response but additional patterns can be supported throughSignalRand WebSockets integration.

WCF SOAP services can be described in WSDL allowing automated tools to generate client proxies even for services with complex schemas.

There is a variety of ways to describe a Web API ranging from auto-generated HTML help page describing snippets to structured metadata for OData integrated APIs.

Ships with the .NET framework.

Ships with .NET framework but is open-source and is also available out-of-band as independent download.

 

 

Use WCF to create reliable, secure web services that accessible over a variety of transports. Use ASP.NET Web API to create HTTP-based services that are accessible from a wide variety of clients. Use ASP.NET Web API if you are creating and designing new REST-style services. Although WCF provides some support for writing REST-style services, the support for REST in ASP.NET Web API is more complete and all future REST feature improvements will be made in ASP.NET Web API. If you have an existing WCF service and you want to expose additional REST endpoints, use WCF and the WebHttpBinding.

Source: MSDN

Tags:

HTTP Error 404.7 - Not Found The request filtering module is configured to deny the file extension.

by Admin 5. November 2013 05:31

HTTP Error 404.7 - Not Found The request filtering module is configured to deny the file extension.

Fix

The fix I made is to enable the request filtering extensions in the config file <requestFiltering>

                <fileExtensions>

                    <add fileExtension="." allowed="true" />

                 </fileExtensions>

             </requestFiltering>

This fix works for both wcf service config or the website you are deploying

Tags:

Deep Copy for an object

by Admin 31. October 2013 06:30

Deep copy especially for List controlls

Please the following two methods in a common class library

public static T DeepCopy<T>(T obj)

        {

            if (obj == null)

                throw new ArgumentNullException("Object cannot be null");

            return (T)Process(obj, new Dictionary<object, object>() { });

        }

 

        static object Process(object obj, Dictionary<object, object> circular)

        {

            if (obj == null)

                return null;

            Type type = obj.GetType();

            if (type.IsValueType || type == typeof(string))

            {

                return obj;

            }

            if (type.IsArray)

            {

                if (circular.ContainsKey(obj))

                    return circular[obj];

                string typeNoArray = type.FullName.Replace("[]", string.Empty);

                Type elementType = Type.GetType(typeNoArray + ", " + type.Assembly.FullName);

                var array = obj as Array;

                Array copied = Array.CreateInstance(elementType, array.Length);

                circular[obj] = copied;

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

                {

                    object element = array.GetValue(i);

                    object copy = null;

                    if (element != null && circular.ContainsKey(element))

                        copy = circular[element];

                    else

                        copy = Process(element, circular);

                    copied.SetValue(copy, i);

                }

                return Convert.ChangeType(copied, obj.GetType());

            }

            if (type.IsClass)

            {

                if (circular.ContainsKey(obj))

                    return circular[obj];

                object toret = Activator.CreateInstance(obj.GetType());

                circular[obj] = toret;

                FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

                foreach (FieldInfo field in fields)

                {

                    object fieldValue = field.GetValue(obj);

                    if (fieldValue == null)

                        continue;

                    object copy = circular.ContainsKey(fieldValue) ? circular[fieldValue] : Process(fieldValue, circular);

                    field.SetValue(toret, copy);

                }

                return toret;

            }

            else

                throw new ArgumentException("Unknown type");

        }

Now do the following in the controller to perform a deep copy

List<EntityClassNode> lstMainList = LoadSampleDropdownlistData();

List<EntityClassNode> lstDeepCopyList = new List<EntityClassNode>();

lstDeepCopyList =commonServiceclass.DeepCopy(lstCacheEntityTreeNode);

Now the operations performed on the lstDeepCopyList will not be referenced on to the main lstMainList 

Tags:

MVC4 gZip for zipping & loading content faster in the browser

by Admin 31. October 2013 06:21

For a MVC application for loading content quicker in the browser we use gzip compression

For this create an Attribute for Compress Content. Make this as a class file within your MVC 4 website. You can download the class file here...compresscontentattribute.cs (2.56 kb)

Next we need to decorate all the controllers with the [CompressContent] attribute or simply make sure you inherit all the controllers from the Base controller and decorate the base controller with the [CompressContent] attribute

Tags:

Cross Frame Scripting attacks on websites

by Admin 31. October 2013 06:08

Cross Frame Scripting:

a)From code: Set the X-FRAME-OPTIONS Http header for modern browsers on every page and include framebreaking code (best effort) as remediation.

b) In IIS: Better approach here..

To configure IIS to add an X-Frame-Options header to all responses for a given site, follow these steps:

  1. Open Internet Information Services (IIS) Manager.
  2. In the Connections pane on the left side, expand the Sites folder and select the site that you want to protect.
  3. Double-click the HTTP Response Headers icon in the feature list in the middle.
  4. In the Actions pane on the right side, click Add.
  5. In the dialog box that appears, type X-Frame-Options in the Name field and type SAMEORIGIN in the Value field.
  6. Click OK to save your changes.
Ref: http:// support.microsoft.com/kb/ 2694329

 

Tags:

The service cannot be activated due to an exception during compilation. The exception message is: Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBinding

by Admin 22. October 2013 11:37

I got the following set of errors When I enabled SSL  HTTPS on my App server where we hosted our  WCF Service

 

1. The service cannot be activated due to an exception during compilation. The exception message is: Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBinding

2. The requested service, 'https://XXXXXXXXXXXX.co.uk/Service/myService.svc' could not be activated. See the server's diagnostic trace logs for more information.

My solution was to add an "s" to the binding value.

Old: binding="mexHttpBinding"  New: binding="mexHttpsBinding"

 <services>

<service name="YourService.Services.SampleService">

        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="msize" contract="YourService.Services.ISampleService" />

        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>

</service>

</services>

<bindings>

      <wsHttpBinding>

        <binding name="msize" maxReceivedMessageSize="2147483647"  receiveTimeout="00:59:00" sendTimeout="00:59:00">

          <security mode="Transport">

            <transport clientCredentialType="None"/>

          </security>

        </binding>

      </wsHttpBinding>

</bindings>

Tags:

Bootstrap styling

by Admin 22. August 2013 02:44

Bootstrap Tabs with ajax data loading

http://ericsaupe.com/tag/bootstrap-3-tabs-example/

Bootstrap Toggle

http://getbootstrap.com/javascript/#collapse

 

Bootstrap buttons

http://www.plugolabs.com/twitter-bootstrap-button-generator-3/

 

http://bootsnipp.com/snipps

http://getbootstrap.com/2.3.2/components.html#dropdowns

http://www.bootstraphero.com/

Tags:

short cut to Format the code in visual studio

by Admin 23. July 2013 07:58

short cut to Format the code in visual studio

 

Ctrl + K + D

Tags:

How to convert date format(dd/MM/yyyy) in MVC3 / MVC4

by Admin 19. July 2013 06:44

To convert date format(dd/MM/yyyy) in MVC3 / MVC4

[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]

This is do the job and can use in the view like @Html.DisplayFor(model => model.StartDate)

But if you want to use the date formatting in a forloop then along with the above use the following approach.

foreach (var item in Model.lstBipActions)
    {
            @Html.DisplayFor(model =>@item.StartDate)

    }

Tags:

The launch of the uk replica watches new timepiece series undoubtedly symbolizes the replica watches history of the brand, and the classic hublot replica watches design explains the mission of the replica watches uk brand's precision watchmaking.

TextBox

Tag cloud

    RecentPosts