Angular Form Validation

Hi all,

Ok this is my very first ever screencast, It’s not very polished but hopefully I’ll get into the swing of things with some more practise.

The screen cast shows how to add validation to forms the Angular.JS way.

 

image

 

 

image

image

Angular.js Auth with ASP WebApi2

So in my previous post I show you how to auth with a bearer token against WebApi2 with the OWIN middleware using a HttpClient. Next up I show you how to do the same with AngularJS.

AngularJS

True to form I’m not going to write a big long blog post on this topic, there are many others that are better than mine. There are even a nice few github hosted solutions you can grab for yourself.

I ended up picking the first post I saw, http://www.codeproject.com/Articles/742532/Using-Web-API-Individual-User-Account-plus-CORS-En

Now lets ignore the CORS part for starters (have banged my head against the walls many times over that).  In order to get this working with the latest and greatest web api as of this post you’ll need two little tweaks

1) Relative URL

The author posts the following code

image

You’ll need to change the baseUrl to an empty string, if you leave it this way (even when correcting the port) you’ll end up in a CORS situation and you’ll see the browser send an OPTIONS request which you don’t want. (in fairness the author was showing CORS working so there is nothing wrong with his/her post).

 

2) Token Payload

image

The important part is that i create a new object ‘data’ and this contains the querystring for the POST body, in the $http call, I then pass data rather than userData like the codeproject article shows.

That’s it, you should now be up and running.

NDepend

Hi all, I’d like to introduce you to what appears to be a great tool for the .net platform. http://www.ndepend.com/

image

I’ve promised to write a review on this tool, however, I’ll be perfectly honest and admit, that I’ve just not got the time right now, so I’m going to take a short cut.

Podcasts

I listen to a lot of podcasts mostly when driving or cycling, recently I’ve started listening to a new podcast http://www.codingblocks.net/ it’s a good podcast and I hope it continues to stick around. As it turns out this podcast did a review on NDepends http://www.codingblocks.net/podcast/ndepend-on-how-good-your-code-is/ and I encourage you to check it out. Moreover; in a more recent episode they mention that they’ve received feedback from Patrick Smacchia (Lead Developer and brains behind the tool) and the feedback they’ve received from Patrick on the few little niggles they encountered is quite positive and upbeat.

When I find myself looking for some tooling like this I’ll write a proper review of my own, but until then based on my interactions with Patrick and after listening to the podcast above, I encourage you, that if you’re in the market for such analysis tools to take NDepends for a spin, and let us know how you get on!

WebAPI OWIN and HppClient Authorize

Hi all, I know I promised my next post was going to be more Azure but I encountered a little task that took me a while to get working, the scenario was that I wanted to make a call to my WebAPI (MVC5) service using a C# HttpClient, the problem was that the resource I wished to access had the AuthorizeAttribute set

image

 

Now there’s a few ways to skin a cat but in the presence of the default Token Authorization one needs to first get a token and then use this token in subsequent requests. There is some good documentation using fiddler here: http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api, however, there was not a lot of information on how to do this with HttpClient against Katana/Owin/MVC5, rather this information was not available in one specific place.

How

image

The first request gets the token and then this token is used as the Bearer for further requests.