Sunday, 30 September 2018

Azure Service Fabric Mesh

Service Fabric Mesh
Azure Service Fabric Mesh is an extension of the Azure Service Fabric. In another words, we can also say that it is a kind of Serverless version of Azure Service Fabric.

Azure Service Fabric Mesh is a fully managed service which works on “code and deploy” fashion. It enables developers to develop & deploy Microservices applications without managing virtual machines, storage, networking, or infrastructure. It works by analyzing the resource requirements of each application and the available infrastructure, then automatically scales, rolls out upgrades and self-heals whenever it’s required.
The platform supports both Linux and Windows containers, Microsoft said.
With Azure Service Fabric Mesh, developers can deploy container-based Microservices directly from the Azure Portal or Command Line Interface, or from within Microsoft’s integrated development environment Visual Studio.             

Azure Service Fabric Mesh tools that allow developer to debug and publish their apps to cloud. Once it’s deployed, Azure Service Fabric Mesh runs in the background, automating functions such as scaling, service discovery and other maintenance tasks.

The people who are using Visual Studio for their development work need to do below two things to start development for Azure Service Fabric Mesh:

1.      They need to download & Install Azure Service Fabric Mesh tools from
2.      They also need to download & install MicrosoftAzure-ServiceFabric-SDK-Mesh at his machine.

Once you install these two things, you can start seeing below project templates in your Visual Studio:

You can create both frontend and backend application using these templates. To create frontend application, you can select “Web Application” or “Web Application (MVC)” project template and for backend application, you can select “API” project template.

Once you create your project, you can see your project structure as below:

You can download the complete sample from below link:

Saturday, 5 September 2015

Page Directives in ASP.NET

Page directives configure the runtime environment that will execute the page. The complete list of directives is as follows:
  1. @ Page - Defines page-specific attributes used by the ASP.NET page parser and compiler and can be included only in .aspx files.
  2. @ Register - Associates aliases with namespaces and classes, which allow user controls and custom server controls to be rendered when included in a requested page or user control.
  3. @ Assembly - Links an assembly to the current page or user control declaratively. 
  4. @ Control - Defines control-specific attributes used by the ASP.NET page parser and compiler and can be included only in .ascx files (user controls).
  5. @ Implements - Indicates that a page or user control implements a specified .NET Framework interface declaratively. 
  6. @ Import - Imports a namespace into a page or user control explicitly.
  7. @ Master - Identifies a page as a master page and defines attributes used by the ASP.NET page parser and compiler and can be included only in .master files.
  8. @ MasterType - Defines the class or virtual path used to type the Master property of a page.
  9. @ OutputCache - Controls the output caching policies of a page or user control declaratively.
  10. @ PreviousPageType - Creates a strongly typed reference to the source page from the target of a cross-page posting.
  11. @ Reference - Links a page, user control, or COM control to the current page or user control declaratively.

Page Life Cycle in ASP.NET

  • Page_PreInit
  • Page_Init
  • Page_InitComplete
  • Page_PreLoad
  • Page_Load
  • Page_LoadComplete
  • Page_PreRender
  • Render

Generalization & Specialization in OOPS

The concept of generalization in OOP means that an object encapsulates common state and behavior for a category of objects.

Example: The geometric shape is an object and most geometric shapes have area, perimeter, and color.

The concept of specialization in OOP means that an object can inherit the common state and behavior of a generic object. However, each object needs to define its own special and particular state and behavior.

Example: Each geometric shape has its own color and particular formulas to calculate its area and perimeter.

Various .Net Tools

What is Ilasm.exe used for?
Ilasm.exe is a tool that generates PE files from MSIL code. You can run the resulting executable to determine whether the MSIL code performs as expected.

What is Ildasm.exe used for?
Ildasm.exe is a tool that takes a PE file containing the MSIL code as a parameter and creates a text file that contains managed code.

What is the ResGen.exe tool used for?
ResGen.exe is a tool that is used to convert resource files in the form of .txt or .resx files to common language runtime binary .resources files that can be compiled into satellite assemblies.

Strong Name Tool (Sn.exe) used for?
Sn.exe is a tool that is used to generate strong name. eg: sn -k mykey.snk

What is the caspol.exe tool used for?
The caspol tool grants and modifies permissions to code groups at the user policy, machine policy, and enterprise policy levels.

Some more tool will be added shortly ! Please wait.... 

A short description about .Net Assembly

What is an assembly?
An assembly is a collection of one or more .exe or dll’s. An assembly is the fundamental unit for application development and deployment in the .NET Framework.
An assembly contains a collection of types and resources that are built to work together and form a logical unit of functionality.

What are the contents of assembly?
A static assembly can consist of four elements:
1. Assembly manifest - An assembly manifest contains the information about the identity and version of the assembly. It also contains the information required to resolve references to types and resources.
2. Type metadata - Binary information that describes a program.
3. Microsoft intermediate language (MSIL) code.
4. A set of resources.

What are the different types of assembly?
1. Private assembly: A private assembly is installed in the installation directory of an application and is accessible to that application only.
2. Shared assembly: Shared assembly is shared by multiple applications. A shared assembly has a strong name and is installed in the GAC.
3. Satellite assembly: Satellite assemblies are often used to deploy language-specific resources for an application.

What is a dynamic assembly?
A dynamic assembly is created dynamically at run time when an application requires the types within these assemblies.

What is a strong name?
You need to assign a strong name to an assembly to place it in the GAC and make it globally accessible. A strong name consists of a name that consists of an assembly's identity (text name, version number, and culture information), a public key and a digital signature generated over the assembly.
The .NET Framework provides a tool called the Strong Name Tool (Sn.exe), which allows verification and key pair and signature generation.

What is GAC? What are the steps to create an assembly and add it to the GAC?
The global assembly cache (GAC) is a machine-wide code cache that stores assemblies specifically designated to be shared by several applications on the computer. You should share assemblies by installing them into the global assembly cache only when you need to.
Create a strong name using sn.exe tool eg: sn -k mykey.snk
In AssemblyInfo.cs, add the strong name eg: [assembly: AssemblyKeyFile("mykey.snk")]
recompile project, and then install it to GAC in two ways :
Drag & drop it to assembly folder (C:\WINDOWS\assembly OR C:\WINNT\assembly) (shfusion.dll tool)
gacutil -i abc.dll

Thursday, 31 July 2014

Increasing request limit quota in WCF/REST Service

Customizing webHttpBinding in web.config and referencing with bindingConfiguration in endpoint element
        <behavior name="AmmuEndPointServiceBehavior">
          <webHttp />
        <behavior name="AmmuServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
      <!-- Customizations for REST service -->
        <!-- Limits set to 10 MB (specified value in bytes) -->
        <binding name="AmmuBinding" maxReceivedMessageSize="10485760" maxBufferPoolSize="10485760" maxBufferSize="10485760" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
          <readerQuotas maxDepth="32" maxStringContentLength="10485760" maxArrayLength="10485760" maxBytesPerRead="10485760" />
          <security mode="None" />
      <service name="Amalay.Web.Services.AmmuService" behaviorConfiguration="AmmuServiceBehavior">
        <endpoint address="" binding="webHttpBinding" contract="Amalay.Web.Services.IAmmuService" bindingConfiguration="AmmuBinding" behaviorConfiguration="AmmuEndPointServiceBehavior" />

    <serviceHostingEnvironment aspNetCompatibilityEnabled= "true" multipleSiteBindingsEnabled="true"  />


HTTP status codes

1xx – Informational: These status codes indicate a provisional response. The client should be prepared to receive one or more 1xx responses before receiving a regular response.

100 - Continue.
101 - Switching protocols.

2xx – Success: This class of status codes indicates that the server successfully accepted the client request.

200 - OK. The client request has succeeded.
201 - Created.
202 - Accepted.
203 - Non-authoritative information.
204 - No content.
205 - Reset content.
206 - Partial content.
3xx – Redirection: The client browser must take more action to complete the request. For example, the browser may have to request a different page on the server or repeat the request by using a proxy server.

301 - Moved Permanently
302 - Object moved Temporarily
303 - See Other
304 - Not modified.
307 - Temporary redirect.
4xx - Client Error: An error occurs, and the client appears to be at fault. For example, the client may request a page that does not exist, or the client may not provide valid authentication information.

400 - Bad request.
401 - Access denied. IIS defines a number of different 401 errors that indicate a more specific cause of the error. These specific error codes are displayed in the browser but are not displayed in the IIS log:

403 - Forbidden. IIS defines a number of different 403 errors that indicate a more specific cause of the error:

404 - Not found. 404.0 - (None) – File or directory not found.

405 - HTTP verb used to access this page is not allowed (method not allowed.)
406 - Client browser does not accept the MIME type of the requested page.
407 - Proxy authentication required.
412 - Precondition failed.
413 – Request entity too large.
414 - Request-URI too long.
415 – Unsupported media type.
416 – Requested range not satisfiable.
417 – Execution failed.
423 – Locked error.

5xx - Server Error: The server cannot complete the request because it encounters an error.

500 - Internal server error.

501 - Header values specify a configuration that is not implemented.
502 - Web server received an invalid response while acting as a gateway or proxy.

503 - Service unavailable. This error code is specific to IIS 6.0.
504 - Gateway timeout.
505 - HTTP version not supported.

Removing HTML tags from Input String in Sql Server

    DECLARE @Start INT, @End INT, @Length INT;
        SET @Start  = CHARINDEX('<', @INPUT_STRING);
        SET @Length = (@End - @Start) + 1;
        IF @Length > 0
            SET @INPUT_STRING = STUFF(@INPUT_STRING, @Start, @Length, '')

Thursday, 19 September 2013

New features in C# 4.0

The major theme for C# 4.0 is dynamic programming. Increasingly, objects are “dynamic” in the sense that their structure and behavior is not captured by a static type, or at least not one that the compiler knows about when compiling your program. Some examples include

Objects from dynamic programming languages, such as Python or Ruby
COM objects accessed through IDispatch
Ordinary .NET types accessed through reflection
Objects with changing structure, such as HTML DOM script objects
Data readers and other user defined dynamic objects

While C# remains a statically typed language, we aim to vastly improve the interaction with such objects.
A secondary theme is co-evolution with Visual Basic. Going forward we will aim to maintain the individual character of each language, but at the same time important new features should be introduced in both languages at the same time. They should be differentiated more by style and feel than by feature set.

The new features in C# 4.0 fall into four groups:
Dynamic binding
Dynamic binding allows you to write method, operator and indexer calls, property and field accesses, and even object invocations which bypass the C# static type checking and instead gets resolved at runtime. 

Named and optional arguments
Parameters in C# can now be specified as optional by providing a default value for them in a member declaration. When the member is invoked, optional arguments can be omitted. Furthermore, any argument can be passed by parameter name instead of position.

COM specific interop features
Dynamic binding as well as named and optional arguments help making programming against COM less painful than today. On top of that, however, we are adding a number of other features that further improve the interop experience specifically with COM.

It used to be that an IEnumerable<string> wasn’t an IEnumerable<object>. Now it is – C# embraces type safe “co-and contravariance,” and common BCL types are updated to take advantage of that.

I will come with more details on this in next blog....