Getting up to speed with Docker

I have to admit I am a bit late to the party, I’ve been hearing a lot about Docker for a couple of months mainly due to the announcements related to “Docker” support in Azure. I never really took time to understand and learn more about it until recently. I’m really glad I took some time to get started with Docker as I feel like Its going to be a very disruptive technology platform and you are going to need to know about it at some point. This post is aimed at anyone completely new to this to quickly get up to speed.

Overview – See this link on Docker web site that gives a pretty good overview, be sure to watch intro video by Solomon Hykes where he explains the problem and how Docker solves it. https://www.docker.com/whatisdocker/ 

Understanding Docker – Excellent article that covers everything you need to understand about Docker https://docs.docker.com/introduction/understanding-docker/

Docker Tutorial

Docker team has put together an excellent tutorial here https://www.docker.com/tryit/

Docker Windows Client

Microsoft has done some work already on getting Docker CLI compiled on a Windows machine. Check out this article that walks through getting Docker CLI compiled on Windows https://ahmetalpbalkan.com/blog/compiling-docker-cli-on-windows/

There is even an ASPNET vNext Docker image on Docker repository. https://registry.hub.docker.com/u/microsoft/aspnet/

Resources related to Docker support on Azure

I’ve compiled a list of links that discuss Docker support on Microsoft Azure.

Hopefully you get excited about this platform as much as I am. In very short time its caught so much attention and grown insanely.

Hope this helps

</Ram>

Anonymous access + Azure AD authentication in Azure Websites or WebRole

By default when you create an ASP.NET web application in Visual Studio and use Organization Authentication, Visual Studio assumes that the entire site is an authenticated site and adds a “<deny users=”?” />” to web.config which causes a redirect to Azure AD for auth page every time you run the web application. Now if you have an anonymously accessible site + secured authenticated areas, there are some additional steps you’ll need to perform and that’s what I will cover in this post

Assuming you have created an ASP.NET web application and used organization auth to hook into your Azure AD tenant for authentication and authorization capabilities for your web site. First thing we’ll need to do is comment out <deny users=”?”> element under authorization element in web.config

Add a new Action method to your “AccountController.cs” file and name it “Signon”, if you don’t like this method name you can change it to something else you prefer. We are going to add some code in this method to generate the Azure AD login URL. I’m going to paste the code that is needed below, just grab it from here.

[ChildActionOnly]

public ActionResult SignOn()

{

    ViewBag.LoginUrl = GetSignInUrl();

    return PartialView("_LoginPartial");

}

private String GetSignInUrl()

{

    WsFederationConfiguration config = FederatedAuthentication.FederationConfiguration.WsFederationConfiguration;

    string replyUrl = Url.Action("SignOnCallBack", "Account", routeValues: null, protocol: Request.Url.Scheme);

    var signInRequest = new SignInRequestMessage(new Uri(config.Issuer), IdentityConfig.Realm, replyUrl);

    signInRequest.SetParameter("wtrealm", IdentityConfig.Realm ?? config.Realm);

    return signInRequest.RequestUrl;

}

Next we’ll modify the “_LoginPartial” partial view, this is generated by default when you created the project using project template. In my example I’m using some bootstrap classes to show a user dropdown menu that contains few menu items, you can completely customize this the way you like for your scenario. Here is what I have for the site I’m working on

<div class="btn-group">

    <a class="btn btn-primary" href="#"><i class="fa fa-user fa-fw"></i> @User.Identity.Name</a>

    <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">

        <span class="fa fa-caret-down"></span>

    </a>

    <ul class="dropdown-menu">

        @if (Request.IsAuthenticated)

        {

            <li><a href=@Url.Action("Profile", "Account")><i class="fa fa-pencil fa-fw"></i> Profile</a></li>

            <li class="divider"></li>

            <li><a href=@Url.Action("SignOut", "Account")><i class="fa fa-sign-out fa-fw"></i> Sign Out</a></li>

        }

        else

        {

            <li><a href="@ViewBag.LoginUrl"><i class="fa fa-sign-in fa-fw"></i> Login</a></li>

            <li class="divider"></li>

            <li><a href="#signup-modal" data-toggle="modal"><i class="fa fa-credit-card fa-fw"></i> Sign Up</a></li>

        }

    </ul>

</div>

Lastly we’ll need to modify the layout to load the _loginPartial view, depending on your site branding and where you need to surface the login control, simply add following razor code

@{Html.RenderAction("SignOn", "Account");}

That’s it.

Hope this helps

Thanks,

</Ram>

How I’m using dependency injection with IoC container in Azure WorkerRoles

In this post I will cover how I’m using dependency injection with an IoC container inside of Azure worker roles. I’m assuming you all are familiar with DI and IoC containers but just incase anyone is not at a high level it allows us to build a decoupled system that is testable.

I’m also using Microsoft’s CommonServiceLocator to get to my ninject container and the reason for this is it provides a nice abstraction layer in the event I decided to replace my IoC container from ninject to some thing else, additionally I don’t have to pass around the reference of IKernel via parameter or something where constructor injection is not possible.

Nuget Packages you will need to pull down

You’ll need to pull down following nuget packages, you can run following commands in package manager console

install-package Ninject

Install-package CommonServiceLocator

install-package CommonServiceLocator.NinjectAdapter.Unofficial

First two packages, you can easily tell from name what they are, but the last one “CommonServiceLocator.NinjectAdapter” gives you the ninject adapter for common service locator.

When you create a Azure Worker Role project inside of visual studio, by default you are going to get a class called “WorkerRole” that inherits from “RoleEntryPoint” class defined in “Microsoft.WindowsAzure.ServiceRuntime”. If you open this up you can see that the “WorkerRole” class has some code in overridden methods

  • Run – Any code you put here will run for the life time of role instance
  • OnStart – Role initialization code
  • OnStop – Role cleanup code
  • RunAsync

You can also see that by default Run method is wired to “RunAsync” which is were you are supposed to add your code, any code you want to run for the life time of the worker role. This could be things like poling a Queue for messages that needs to be processed etc.

Lets see how we can get DI with Ninject IoC container hooked into worker roles.

First thing I did is I created an abstract class called “NinjectableWorkerRole” that inherits from “RoleEntryPoint” class in my Common Framework assembly that I use in all Azure Projects. NinjectableWorkerRole also implements an IDisposable interface, this is so we can wire up the clean up logic. In this example basically unbinding all the dependencies that we registered with IoC container.

Then I moved all the default code that was in the “WorkerRole” class, additionally I added following abstract methods

protected abstract void RegisterServices(IKernel kernel);

protected abstract void UnRegisterServices(IKernel kernel);

protected abstract void DoWork();

I also added a private variable to this class IKernel _kernel. Next thing we need to do is add some code to OnStart to initialize Ninject as you can see in code snippet below

//create ninject IoC container

_kernel = new StandardKernel();

 

//Tell common service locator to use Ninject IoC container

ServiceLocator.SetLocatorProvider(() => new NinjectServiceLocator(_kernel));

 

//register services, override this in descendant classes and register dependencies with ninject

RegisterServices(_kernel);

Next thing we need to do is wire up the clean up logic, so to do that I defined a method called “Dispose” that can be overridden in descendant classes. In this method we check to see if disposing flag is true and if _kernel is not null we simply call dispose method on kernel and set the reference to null. See code snippet below

protected virtual void Dispose(bool disposing)

{

    if (disposing)

    {

        if (_kernel != null)

        {

            _kernel.Dispose();

            _kernel = null;

        }

    }

}

Inside of Dispose method on IDisposable interface we simply call the above Dispose method by passing “true” as parameter and call SuppressFinalize method on GC. You are probably familiar with this as its the standard way of implementing IDisposable in C#

Last thing is modify the RunAsync code to wire up call to abstract method DoWork

At this point “NinjectableWorkerRole” class is ready, only thing remaining is modifying the existing WorkerRole class in your WorkerRole project to use “NinjectableWorkerRole” class instead of default out of the box RoleEntryPoint class and override RegisterServices, UnRegisterServices and Do Work method. See sample code below

public class WorkerRole : NinjectableWorkerRole

{

    protected override  void RegisterServices(IKernel kernel)

    {

        kernel.Bind<IHelloWorld>()

            .To<HelloWorld>();

        kernel.Bind<INames>()

            .To<MyName>();

    }

    protected override void UnRegisterServices(IKernel kernel)

    {

        kernel.Unbind<IHelloWorld>();

        kernel.Unbind<INames>();

    }

    protected override void DoWork()

    {

        var hw = ServiceLocator.Current.GetInstance<IHelloWorld>();

        Trace.TraceInformation(hw.Message);

    }

}

I’ll add the entire code for NinjectableWorkerRole class to a github repository at some point.

Hope this helps

</Ram>

Enabling Web API on an existing MVC project

If you are in a situation where you started off with an MVC project and realize later you need to add some APIs because you are doing single page apps or what ever, this post I will cover steps you can take to enable Web API on an existing MVC project.

In Nuget Package Manager Console, make sure the MVC project is selected in default project dropdown list and run the command below

Install-Package Install-Package Microsoft.AspNet.WebApi

Right click on your “App_Start” folder and add a new class and name it “WebApiConfig”

Add following using statement

using System.Web.Http

and add a new method called “Register” that takes a parameter named “config” which is of type HttpConfiguration as shown below

public static void Register(HttpConfiguration config)

{

    // Web API configuration and services

 

    // Web API routes

    config.MapHttpAttributeRoutes();

 

    config.Routes.MapHttpRoute(

        name: "DefaultApi",

        routeTemplate: "api/{controller}/{id}",

        defaults: new { id = RouteParameter.Optional }

    );

}

next we need to edit code in “global.asax” add following using statement

using System.Web.Http

Add a call to GlobalConfiguration.Configure passing the Register method that we defined earlier in “WebApiConfig” class as shown below

GlobalConfiguration.Configure(WebApiConfig.Register);

Add a folder “api” to your MVC project and under that create another folder called “Controllers”, this is where you can add all your api controllers

Enabling Web API Help Pages

For those who don’t know what it is, Web API help pages generates pretty nice documentation for your API. Assuming you enabled Web API on an existing MVC project, next thing you’ll likely want to do is get Web API help pages. To enable Web API help pages you simply need to pull down “Microsoft.AspNet.WebApi.HelpPage” package from nuget, you can go to nuget package manager console and run following command “Install-Package Microsoft.AspNet.WebApi.HelpPage”

Hope that helps

Thanks,

</Ram>



No goal too big, No challenge unattainable

Exactly this time last year I set a goal to run 1K miles in 2014 and I’m extremely happy to say yesterday I crossed 1K miles. When I was thinking about doing this challenge I thought “man running 1K miles are you kidding ?”. At 42 I really had doubts about being able to accomplish it. So I broke the overall goal down to how much I needed to run monthly, it roughly came about 83 mile a month, which felt attainable. Breaking down further into weekly goals, it was roughly little over 20 miles a week. All of a sudden goal I thought I simply could not achieve felt achievable

So I set out to do it keeping my focus on how much I needed to run weekly not really thinking much about the overall goal. Weeks I felt good I would log as much runs as I can. I was pretty sure there will be some set backs during certain months, which indeed happened, luckily it wasn’t any running related injuries. First set back was in July had my brother and family visiting and was out sightseeing etc. so couldn’t do much running. Entire month of July I ran about 35 miles and the second one was in Sept as my dad passed away :( and had to be out of the country. Running was the last thing in my mind.

This challenge taught me few things.

  1. No goal or challenge or problem is too big, if you simplify it down
  2. Have contingencies when things take turn for the worse
  3. Stick to the plan, don’t make too many changes too fast, give it some time for things to work out

Here is a monthly break down of my running in 2014

image

My goal for 2015 is to run the Seattle rock n roll marathon in June and Seattle Marathon in Nov.  When I’m not training for Marathon plan to keep running average 20 miles a week.

Going through this challenge has had a major impact on me both mentally and physically. At 42 approaching 43 I’m leaner, thinner than I can imagine for a very long time (going back to college days)

What will you do in 2015?

Have a very Happy and Prosperous 2015, may all your dreams come true

Cheers,

</Ram>

Using VisualStudio web test for automating API testing

If you look at some of the core guiding principles of modern web applications design, IMO almost all of them have at least following characteristics listed below

  • Mobile first
  • Single Page App (SPA)
  • REST API

In this article I will cover how you can use web test in VisualStudio to automate API testing. Hopefully you guys who are developing modern applications with these guiding principles in mind will find this useful. I want to emphasize that this article is not about REST API design, but it is all about testing REST APIs.

You might be wondering why automate, why not use POSTMAN or some other REST client to verify?.  investing some time in test automation will ensure quality, additionally these tests can be valuable for API developers. Once integrated into integration build process, they can provide immediate feedback to API developers in the event some change caused regression issues.

Obviously we cannot talk about API testing in the article with out having some API to work with, so for that what I have done is following

  1. Deployed Northwind Sample SQL database into a SQL Azure instance on my Azure subscription
  2. Developed REST APIs against the Northwind sample database that provides full CRUD access to entities listed below. For the purposes of this article we will only cover testing the customer service, rest of the APIs are there if you need to get hands on experience building web performance tests against it. 
    • Customer
    • Order
    • Product
    • Supplier
    • Shipper
  3. I’ve also deployed the REST APIs to my windows azure subscription, for information about API check out the API help page here. Update: 1/13/2015 API deployment has now been taken down to prevent charges from Azure. If you are interested in the entire source drop me a line via comment or email

Currently the Get operation implements following requirements

  1. Returns a list of northwind customers, default 10 records.
  2. Provide a count of total customers, current page size and page number.
  3. Ability to control the number of records returned
  4. Jump to a specific page in result set
  5. Returns URI for getting to the next set and previous set as relevant to the consumer. When the page number is 1 URI to get to previous set will be null, when accessing the last page, URI to get to next set will be null, all other cases, URI for getting to previous and next set is returned to consumer.

Test Cases for Get Operation

  1. Submit a “Get” request to “http://northwindapi.cloudapp.net/api/customers”, this is the REST endpoint for getting list of customers
    • Verify Response Status code of 200 is received from server
    • Verify count of total customers, current page size and page number is received in response
    • Verify default 10 customers exists in response
    • Verify URI to get to next set is returned in response
  2. Submit a “Get” request to “http://northwindapi.cloudapp.net/api/customers”. Set pageNo querystring parameter value to 2
    • Verify URI to get to next set and previous set is returned in response
  3. Submit a “Get” request to “http://northwindapi.cloudapp.net/api/customers”. Set pageSize querystring parameter value to 20
    1. Verify 20 customers exists in response

You can see from the above list of test cases that they cover all the requirements defined for the API. Keeping this in mind let now look at automating our API testing.

Create a new project by selecting “web performance and load test project” template. After the project is created you’ll see a WebTest1.webtest file in the project, rename this to CustomerAPITests.webtest.

I also created an XML file that contains the test data that I want to use and added to “Data” folder in my test project. We’ll add this as a data source for the web test

In the new test data source wizard, specify a name for test data source and select XML file for data source type and click next, see screenshot below

captureds

Choose the xml file, select table and clicking finish will add the xml data source to webtest

addds

Now let’s Add a web service request to our webtest by right clicking on the test case UI and click on “Add Web Service Request” as shown in screenshot below

addwsrequest

Next we need to parameterize web servers so we don’t have to hard code the web server host names in URL, this is useful when you are sending multiple web service requests in one web test. Parameterize web server option is available in toolbar within the test case surface. You can also right click on “CustomerAPITests” and click on “parameterize web servers” option

paramws

In “Parameterize web server” dialog click on “Change” as shown in diagram below.

paramws1

In the “change web server” dialog rename the the context parameter name to “Azure” and Web Server to “http://northwindapi.cloudapp.net”

paramws2 

Configure “Expected HTTP Status Code”, “Method” and Url for the web service request by right clicking on the web service request and clicking on “properties”. See screenshot below.

prop1

At this point we have a web service request configured to hit our “api/customers” end point which will return a list of customers from our northwind database. As a part of our first test case we also need to verify that we get a count of total customers, page size, page number, URI for getting next resultset and also verify that the response contains only 10 customers by default, we are going use a custom extraction rule & validation rule to accomplish this.

For more information on using extraction rules and validation rules in web tests see http://msdn.microsoft.com/en-us/library/vstudio/bb385904%28v=vs.110%29.aspx

I created a folder named “Custom Extraction Rules” in my test project, this folder will contain the code files for the custom extraction rules. Code below shows the JSON extraction rule to extract tokens from JSON response

[DisplayName("Extract JSON rule")]

[Description("Custom extraction rule for extracting values from JSON web response generated by web performance test")]

public class JsonExtractionRule : ExtractionRule

{

    public String Token { get; set; }

    public override void Extract(object sender, ExtractionEventArgs e)

    {

        var jsonString = e.Response.BodyString;

        var json = JObject.Parse(jsonString);

        JToken jToken = null;

        if (json == null)

        {

            e.Success = false;

            e.Message = "Response received not in JSON format";

        }

        else

        {

            jToken = json.SelectToken(Token);

            if (jToken == null){

                e.Success = false;

                e.Message = String.Format("{0} : Not found", Token);

            }

            else

            {

                e.Success = true;

                e.WebTest.Context.Add(this.ContextParameterName, jToken);

            }

        }

    }

}

We can now add extraction rules to verify we are getting a count of total customers, page number, page size and URI to get to next set in JSON response.

Right click on web service request and click on “Add extraction Rule” option to add a new extraction rule

extractionrule

In the add extraction rule dialog select “Extract JSON rule” this is the custom extraction rule we created earlier. Specify “paramTotalCustomers” for Context Parameter Name option and for Token under properties specify “totalCustomers”, rule will look for this token in JSON response.

extractionrule1

Do the above steps for “pageNo”, “pageSize”, “nextPageLink”

Now lets add a custom validation rule to verify we are indeed getting the number of items we want (controlled by “pageSize”) in response

Code for custom validation rule to check result count

[DisplayName("Result count validation rule")]

[Description("This rule checks to see the REST API returns number of items requested")]

public class ValidateResultCount : ValidationRule

{

    

    public String PageSizeElementPath { get; set; }

    public String ResultElementPath { get; set; }

    public override void Validate(object sender, ValidationEventArgs e)

    {

        var jsonString = e.Response.BodyString;

        var json = JObject.Parse(jsonString);

        if (json == null)

        {

            e.IsValid = false;

            e.Message = "Response received not in JSON format";

        }

        else

        {

            //extract pageSize from response

            var pageSizeJToken = json.SelectToken(PageSizeElementPath).Value<Int32>();

            var resultsJArray = json.SelectToken(ResultElementPath).Value<JArray>();

            if(resultsJArray.Count != pageSizeJToken)

            {

                e.IsValid = false;

                e.Message = "Results count does not match the page size";

            }

            else

                e.IsValid = true;

        }

    }

}

At this point first test case is full automated. For test case 2 I added another web service request to the web test and added query string parameter to specify pageNo and added two JSON extraction rules to look for “previousPageLink” and “nextPageLink”

Lastly for test case 3 I added a third web service request to the web test and added query string parameter to specify pageSize and the custom result count validation rule to verify pageSize and the number of customer records returned match.

Screenshot below shows completed webtest that automates all three test cases.

webtest3

As you can see from the screen shot below all three requests ran successfully, we can be sure that the service is functioning as expected.

webtest4

Additional requests “PUT” and “POST” can be added the the web test as a part of automating API testing.

Hope this helps

Cheers,

</Ram>

Integrating ASPNET MVC views into SharePoint

Introduction

In this post I will cover an approach you can use to surface MVC views into SharePoint pages. I’m also making an assumption that you are familiar with ASPNET MVC, if you are new to ASPNET MVC have a look at this link http://www.asp.net/mvc

Approach

mvcspintegration

Assuming you have developed and published your MVC application to one or more IIS web severs, to surface the MVC views inside a SharePoint page, we can simply create a new content page and add a ‘div” container element, along with some javascript to make Ajax request to MVC controller. After successful completion of request, response is then injected into container “div” element using jQuery.

Snippet below shows HTML markup and JavaScript that can be added to SharePoint page where MVC views needs to be surfaced:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>

<script type="text/javascript">

_spBodyOnLoadFunctions.push(function(){

$.ajax({

                type: "GET",

                url: "http://controls.ram.dev/home/documents",

        beforeSend: function(){

            $("#mvchost").html('<img src="/_layouts/images/ajax-loading.gif" />');            

        },

                success: function (result) {

                    $("#mvchost").html(result);

                },

                error: function (xhr, status, error) {

                    alert(error);

                }

            });

});

</script>

<div id="mvchost"></div>

Cross domain scenarios

Because of the same origin policy, cross domain ajax requests are not allowed, so if your SharePoint site and MVC application have different URLs, ajax requests originating from SharePoint site will fail. We can have script tags that loads javascript files from other domains. JSONP uses this approach in order to make cross domain requests by dynamically creating a script tag with necessary URL, On the server you have to wrap the data (typically in JSON format) in a function call (callback). When the script is loaded browser will call the callback function and passes the loaded data. Keeping this in mind we’ll need to make some changes to your MVC application to support cross domain ajax requests.

Adding JSONP support to JsonResult

Methods in controller return “ActionResult”, If you are new to MVC and is not quite familiar with what “ActionResult” is see this blog post http://rachelappel.com/asp.net-mvc-actionresults-explained. There is “JsonResult” class available by default within System.Web.Mvc which is used to send JSON formatted content to the response, we’ll need to extend this to support JSONP

Add a new class to your MVC project and name it “JsonpResult”, derive this class from “JsonResult”. Override the ExecuteResult method to generate callback function call with data wrapped. See code below for “JsonpResult” class

public class JsonpResult : JsonResult

{

    public string Callback { get; set; }

 

    public override void ExecuteResult(ControllerContext context)

    {

        if (context == null)

        {

            throw new ArgumentNullException("context");

        }

 

        this.Callback = context.HttpContext.Request["callback"];

 

        if (string.IsNullOrEmpty(this.Callback))

            throw new ArgumentNullException("Callback required for JSONP response.");

 

        HttpResponseBase response = context.HttpContext.Response;

 

        if (!String.IsNullOrEmpty(ContentType))

        {

            response.ContentType = ContentType;

        }

        else

        {

            response.ContentType = "application/json";

        }

        if (ContentEncoding != null)

        {

            response.ContentEncoding = ContentEncoding;

        }

        if (Data != null)

        {

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            response.Write(string.Format("{0}({1});", this.Callback, serializer.Serialize(Data)));

        }

    }

}

Next thing we’ll need to do is to create an extension method on Controller class to Render view as string, this is so we can send the output as a JSON response.

public static string RenderPartialView(this Controller controller, string viewName, object model)

{

    if (string.IsNullOrEmpty(viewName))

        viewName = controller.ControllerContext.RouteData.GetRequiredString("action");

 

    controller.ViewData.Model = model;

    using (var sw = new StringWriter())

    {

        ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, viewName);

        var viewContext = new ViewContext(controller.ControllerContext, viewResult.View, controller.ViewData, controller.TempData, sw);

        viewResult.View.Render(viewContext, sw);

 

        return sw.GetStringBuilder().ToString();

    }

}

Lastly we’ll need to add an additional action method on Controller that returns JsonpResult (This is the extended JsonResult class we created that can handle cross domain requests using JSONP). In this method you will need to add logic to get data needed for the view and return a new instance of “JsonpResult” as shown in sample below.

var model = null;

 

//Add data Access logic here

 

return new JsonpResult

{

    Data = new {

        success = true,

        message = "View Loaded Successfully",

        view = this.RenderPartialView("{replace with view}", model)

    },

    JsonRequestBehavior = JsonRequestBehavior.AllowGet

};

We will also need to modify the javascript snippet that is added to SharePoint page which will send ajax request to controller to use JSONP because of cross domain scenario. Here is the modified snippet that uses JSONP

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>

<script type="text/javascript">

_spBodyOnLoadFunctions.push(function(){

$.ajax({

                type: "GET",

                url: "http://controls.ram.dev/home/documentsjsonp",

        dataType: "jsonp",

        crossDomain: true,

        beforeSend: function(){

            $("#mvchost").html('<img src="/_layouts/images/ajax-loading.gif" />');            

        },

                success: function (result) {

                    $("#mvchost").html(result.view);

                },

                error: function (xhr, status, error) {

                    alert(error);

                }

            });

});

</script>

<div id="mvchost"></div>

if you notice in above javascript, in the success callback function, I’m grabbing the view markup from result which is now returned as a JSON response from controller action method and injecting into container div using jQuery. Ajax request URL is also different since we have additional action method in controller that returns JSON result for cross domain requests.

Some thoughts on authentication scenarios

If your SharePoint site is configured for SAML Claims authentication, you’ll need to make your MVC application also trust the same identity provider, this will provide SSO across SharePoint and MVC application. Security logic can be added in your controller methods for ex. if you need to retrieve data specific to authenticated user.

I haven’t tested with FBA sites, may be I will create a part 2 of this post to cover some authentication related scenarios.

Additional use cases for this approach

There are some additional scenarios and use cases where the same approach can be beneficial.

  • You are developing custom applications on SharePoint and you either are not on SharePoint 2013 to take advantage of Provider hosted app model or you have some constraints on using App model (In this case controller methods could talk back to SharePoint using SharePoint APIs)
  • You have a need to surface content from other systems into SharePoint

Hope this helps…

Cheers,

</Ram>

Office 2013 – How to get rid of extra space between commands

If you got a non-touch laptop and you use office 2013 and notice extra space between commands on ribbon in office 2013, reason for this is that your office 2013 is in touch optimized mode, follow steps below to switch to optimized for mouse mode which will get rid of the extra spaces between commands.

From the quick access toolbar select “touch/mouse mode” this will bring up an addition item onto the toolbar, see screenshot below

image

Clicking this option will bring up a drop menu which allows you to switch between mouse and touch, switch to mouse and you will find extra spaces between commands on ribbon disappearing. This change is global and affects across the entire office suite, meaning if you change in word, you’ll see it on outlook, excel etc.

Hope this helps someone, thanks to my colleague for this tip

Cheers,

</Ram>

An Introductory post (thisdevmind.com)

This is an introductory post to announce my new site, while I’m certainly not new to blogging, one of the things I realized is that since I started blogging initially on MSDN,  I’ve moved my blog from MSDN to other hosting providers and then coming back to MSDN while not maintaining consistent URL and preserving links to many of my older posts, I realize how frustrating this has been to readers of my blog. Granted not sure if many people read stuff I write :) but still…

I wanted to write this post and set the record straight “I screwed up”, I can assure you this site is here to stay, I’m currently hosting this blog on Azure websites using WordPress. I hope I wont have to move to another provider, even if I do I will take every step to ensure consistency on URL and preserve links to posts so you’ll never see broken links to my posts. Through this site I’m hoping to share information about developing for cloud and devices and hope you will find the site useful. I hope you will stay in touch with me through various options listed in contact page of this site and provide me any feedback you might have on the content here or things I can improve.

Cheers,

</Ram>

Targeting windows 8 platform when developing windows store apps using VS2013 + Win 8.1

Like most of the developers who always like to run on latest and greatest Microsoft software, I too upgraded my machine to Windows 8.1 and VS 2013, Today I was bit disappointed to find out that I could not develop windows store app and target windows 8 platform. When creating new projects in VS2013 using the windows store project templates, 8.1 is picked as a default for me, there is simply no way to change this to 8.0 through the VS UI, I tried editing the csproj file and changing the target platform version from 8.1 to 8.0, while that seem to change the target platform after I reloaded the project it broke a bunch of stuff.

For now it seems like you have to keep both VS 2012 and VS 2013 side by side if you will be doing any windows store app development and want to target 8.0. VS 2013 project templates for windows store apps are designed to work with Windows 8.1 only. I don’t like that I have to have two versions of VS in my dev machine but it is what it is. If you have any work around or suggestions, please post a comment

Thanks,

</Ram>