Tuesday, April 01, 2014

IaaS, PaaS and SaaS Terms Explained

Easy to Understand one-word descriptions of each term (i.e. IaaS means host)

Data Visualization of Vendor Management Responsibility of Services
IaaS - the unit you are gaining is a computer/server. Therefore IaaS is essentially a “physical server box”. An example of this would be going to RackSpace or SoftLayer and leasing a physical box from them. The vendor manages the networking, hard drives (if they fail), hardware of the box, virtualization O/S (if the box is virtualized). You can remote desktop to the box and you manage everything else (shown in the screenshot above). Windows Azure provides IaaS in the form the VM Role (you upload a Windows Server 2008 R2 image and manage the server yourself). PaaS - the unit you are gaining is an application/framework. Therefore PaaS is a “hosted application/framework/tools that you can leverage to build something on. That application is configured on IIS/SQL Server etc and runs on a hardware/virtual system that the vendor manages. An example of PaaS would be Windows Azure (excluding the VM Role) services like web role, worker role, Reporting Services etc. SaaS - the unit you are gaining is business functionality. For example, Gmail is a type of a SaaS mail provider because you don’t have to manage any service yourself and its all done by the vendor (Google in this example).

Saturday, May 18, 2013

MVC - Message Handler

Code to log message received or send from Web API:

 using System;  
 using System.Diagnostics;  
 using System.Net.Http;  
 using System.Text;  
 using System.Threading;  
 using System.Threading.Tasks;  
 namespace Program.Api.Web.ActionFilters  
   /// <br />  
 <br />  
   /// Class to log the request/response received from the client  
   /// </summary>  
   public abstract class MessageHandler : DelegatingHandler  
     protected override async Task<httpresponsemessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)  
       var corrId = string.Format("{0}{1}", DateTime.Now.Ticks, Thread.CurrentThread.ManagedThreadId);  
       var requestInfo = string.Format("{0} {1}", request.Method, request.RequestUri);  
       var requestMessage = await request.Content.ReadAsByteArrayAsync();  
       await IncommingMessageAsync(corrId, requestInfo, requestMessage);  
       var response = await base.SendAsync(request, cancellationToken);  
       byte[] responseMessage;  
       if (response.IsSuccessStatusCode)  
         responseMessage = await response.Content.ReadAsByteArrayAsync();  
         responseMessage = Encoding.UTF8.GetBytes(response.ReasonPhrase);  
       await OutgoingMessageAsync(corrId, requestInfo, responseMessage);  
       return response;  
     protected abstract Task IncommingMessageAsync(string correlationId, string requestInfo, byte[] message);  
     protected abstract Task OutgoingMessageAsync(string correlationId, string requestInfo, byte[] message);  
   /// <summary>  
   /// The logger class which will log to the database or text file  
   /// </summary>  
   public class MessageLoggingHandler : MessageHandler  
     protected override async Task IncommingMessageAsync(string correlationId, string requestInfo, byte[] message)  
       if(WebConfig.LogMessages) // Based on web.config property  
       await Task.Run(() =&gt;  
         Trace.WriteLine(string.Format("{0} - Request: {1}\r\n{2}", correlationId, requestInfo, Encoding.UTF8.GetString(message))));  
     protected override async Task OutgoingMessageAsync(string correlationId, string requestInfo, byte[] message)  
       if (WebConfig.LogMessages)  
       await Task.Run(() =&gt;  
         Trace.WriteLine(string.Format("{0} - Response: {1}\r\n{2}", correlationId, requestInfo, Encoding.UTF8.GetString(message))));  

Monday, December 17, 2012

Passed TOGAF 9 Foundation Exam

Passed my TOGAF 9 foundation exam after months of reading and practice. Glad to see 97% pass mark...

Monday, October 17, 2011

XSLT Rendering–SharePoint 2010 Web Parts


One of the main areas of investment when developing Web Parts is the user interface and the output of (X)HTML code. A Web Part needs to merge transparently into an existing page (Web Part Page or Wiki Page), adhering to the rich and user-friendly layout of the hosting site, which can be a public CMS solution. Nevertheless, the output of the Web Parts can be defined in its CreateChildControls method or, for Visual Web Parts, in the ASCX code of the corresponding visual control. However, you cannot always predict where the Web Part will be hosted; thus, you cannot provide a layout that will be appropriate for
every kind of output.

Of course, you can try to satisfy different layout requirements by just working with Cascading Style Sheets (CSS), but in general, there’s no one-size-fits-all solution. This is an issue that Microsoft had to face when developing SharePoint itself.

Consider how Web Parts such as the SearchCoreResults or the XsltListViewWebPart render their output, to name but a couple of
examples. These native Web Parts accept an XSLT transformation as one of their main parameters and apply that transformation to an XML document that represents the real content of their output.

Often, in real SharePoint solutions that target not only intranet/extranet sites but also public Internet scenarios, you will need to develop custom Web Parts that follow these same basic principles.

This technique is truly powerful because it lets you define a completely custom layout for Web Parts while still sharing common business logic and behavior, but it doesn’t impose any specific constraints about the (X)HTML code to output, so it’s often your best choice in realworld SharePoint Internet solutions.

Sunday, October 16, 2011

Passed Exam 70-667: TS: Microsoft SharePoint 2010, Configuring


Last week, I finally gave the 70-667 exam and passed with 750 marks. The exam was not as easy one would expect. The toughest part were multiple questions where you need to arrange the steps of configuration. I was knowing what all involve in configuration but arranging them in proper steps were bit hard.

So, here is my 1 cent advise on anyone who wants to sit this exam-

  • Go through Wiley Publishing - MCTS Microsoft® SharePoint® 2010 Configuration Study Guide. Follow each step on a test SharePoint Virtual machine
  • Use MeasureUp or other exams and make sure to go through the explanation

If you follow these thoroughly, I am pretty confident that you will be able to pass this exam..ALL the best.

Friday, September 30, 2011

Explanation - Microsoft.SharePoint.SPException: The security validation for this page is invalid.


SharePoint applies a security check whenever you change data through the Server Object Model during HTTP requests. In fact, by default, SharePoint web forms use a form digest control to enforce security. The form digest is a hidden field POSTed by SharePoint webforms and checked by the security infrastructure on the server. When you make changes to objects by using the Server Object Model during an HTTP GET request, this input field will be missing, so by default SharePoint will throw an exception that looks like this excerpt:

Microsoft.SharePoint.SPException: The security validation for this page is invalid.

Similarly, if you send an HTTP POST request with a missing or invalid form digest value, you will receive the same error. This behavior applies only during HTTP requests. Therefore, when you reference the Server Object Model in a class library or a batch tool that runs outside of the ASP.NET pipeline, the security check will not occur. In fact, the check process looks for the
HttpContext.Current variable; if it is null the digest validation will not occur.

With that in mind, if you are developing a webpage that will respond to HTTP GET requests, or a custom web form page that doesn’t inherit from the WebPartPage type and doesn’t use the Form Digest control, you will need to instruct SharePoint to skip the digest validation;otherwise, your code will not work.

To instruct SharePoint to skip the validation, set the Boolean AllowUnsafeUpdates property of the current SPSite or SPWeb to true.

Conversely, when you develop a custom ASPX page, and you want to exploit the security environment provided by SharePoint, you have a couple of choices: you can inherit from WebPartPage, or manually include a FormDigest control in your page.

In the first case you simply need to inherit from the Microsoft.SharePoint.WebPartPages.WebPartPage base class, which internally renders a FormDigest control. Then, in your code, you call the utility method SPUtility.ValidateFormDigest() to check the digest when you POST the page back to the server.

In the latter case you need to include the Microsoft.SharePoint.WebControls.FormDigest control in your page(s), and you still need to invoke the SPUtility.ValidateFormDigest() method to check the digest.

Saturday, August 06, 2011

Handling exception in SharePoint Client Object Model


If you use normal try … catch … finally blocks to handle exceptions in Client Object model, you will need to invoke the server via ExecuteQuery three times(one for each situation). This could lead to performance degradation as well as to a huge stress on the server side. Luckily the Client Object Model provides a class named ExceptionHandlingScope that is specifically defined to support such situations and avoid executing multiple queries against the server.

Refer sample from http://msdn.microsoft.com/en-us/library/ee534976.aspx

ClientContext clientContext = new ClientContext("http://MyServer/sites/MySiteCollection");            

ExceptionHandlingScope scope = new ExceptionHandlingScope(clientContext);

using (scope.StartScope())
using (scope.StartTry())
List oList = clientContext.Web.Lists.GetByTitle("My List");
oList.Description = "In Try Block";

using (scope.StartCatch())
// Assume that if there's an exception, it can only be
// because there is no list with the specified title, so
// create the list.
ListCreationInformation listCreateInfo = new ListCreationInformation();
listCreateInfo.Title = "My List";
listCreateInfo.Description = "In Catch Block";
listCreateInfo.TemplateType = (int)ListTemplateType.Announcements;
List oList = clientContext.Web.Lists.Add(listCreateInfo);

using (scope.StartFinally())
List oList = clientContext.Web.Lists.GetByTitle("My List");
oList.EnableFolderCreation = true;



Under the cover, the ExceptionHandlingScope instance collects activities (internally called ClientAction) to execute on the server side for all the three situations (try, catch, finally). The server will begin executing the code inside the StartTry block, and then in case of failure, it will execute the code in the StartCatch. Whether or not exceptions occurred in the StartTry

block, it will finally execute the code in the StartFinally block. However, the request sent to the server is just one, as well as the response.