Raba - Defend your code RSS 2.0
# Wednesday, January 26, 2011

This is my second post about AppHarbor, I suggest you to read my first impression.

I am reading a lot about continuous deployment lately and AppHarbor provide great implementation for simple web applications deployment.

  1. Source Control – Support Git to host your code
  2. Continuous integration – Check build per commit and run NUnit as part of each build
  3. Deployment Script – Each successful commit can be deploy in one click
  4. Rollback – Even after passing build and tests it can be that you still have bugs, so you can simply check older version and deploy it till you commit a fix


Code and publish is so easy, this is by far this better than using FTP for such things and the option to run tests makes it even more fun.

 


The option to rollback to previous commit\version is trivial but so important. Moreover, by clicking on “show” you can check the build log and see the tests-run.

 


You can click the tests link to read more about each test

 

Tip - UrlParameter does not exist:

When first trying to deploy my code it failed during compilation. I got this output:

  Global.asax.cs(18,67): error CS0103: The name 'UrlParameter' does not exist in the current context

I am not sure why, it could be that I am using early beta (didn’t update for a long time), anyhow I fixed this by changing the global.asax.cs from using UrlParamters.Optional to "". You can read more here: http://haacked.com/archive/2010/02/12/asp-net-mvc-2-optional-url-parameters.aspx

Wednesday, January 26, 2011 11:08:47 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
.Net 3.5 | Asp.net MVC | continuous deployment

# Tuesday, January 25, 2011

Everyone knows Google app engine But what about .net apps? Meet AppHarbor (Thanks Gadi)

So I wanted to give it a chance and after playing for less than an hour:

  • Enable you to build \ host \ deploy web apps
  • Provide both Version control and hosting service
  • Absolutely free (for now)
  • Damn simple

Short tutorial on how to do it:

  1. Create your appharbor account + create new application
  2. Hopefully you have Git installed (msysgit downloads)
  3. Init empty Git repository
        git init test1
  4. Copy your files to this directory (download from here: https://github.com/appharbor/appharbor-splash )
  5. Add files and subdirectories
        git add .
  6. Create your remote repository
        git remote add appharbor https://username@appharbor.com/test-178.git 
  7. Commit your code
        git commit -m 'firstcommit'
  8. Almost forgot, we are working on Git - so don't forget to push...
        git push appharbor master

Till here everything should work but I had a small issue, got this error: error setting certificate verify locations:
I've found out that it is all about versions (git --version) - So check yours and upgrade if needed

Here you can find great cheat sheet for Git commands: http://ionrails.com/2009/08/07/git-commands-adding-and-committing-cheatsheet/

Btw, AppHarbor support Databases and Running unit-testing after successful builds – I will post about those features later on.

Tuesday, January 25, 2011 1:49:00 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
.Net 3.5 | Asp.net MVC | Agile

# Monday, April 21, 2008

This is the main day of TechEd were we had lectures from 8:00 till 19:00 Here are my list of lectures for that day:

Optimizing and Extending ASP.NET Ajax - for going beyond the update panel  - (by Assaf Shely)
This was a lecture of 400, at least that is what they wrote. in reality that was an introduction for Ajax, he explain about the update panel and about JSON. The only thing I want to add from this lecture is all he says about ASP.NET Ajax 3.6 - which can support browser history capabilities.
My grade to Assaf's lecture: 6/10 (a big disappointment)

DDC & ASP.NET MVC (by Noam King)
DDC - dynamic data controls (you can read here), MVC - Model View Controller (you can read more in my last post about ASP.NET MVC).
Noam showed a simple usage of the MVC API, and a simple creation of a web site from the DDC API, those both samples are the simple web casts you can find and learn in 15 minutes. a big waste of time (again)
My grade to Noam's lecture: 8/10 (Noam is a great lecturer, the problem was the level of the lecture - All they should do is to write: Intro at the beginning of the lecture description)

Service Host Customization (by Eyal Vardi)
Finally a great lecture for the second day. It was a great one. you can download the lecture here.
Eyal showed a great sample for Config manager - which helps you manage your configurations details (addresses for example) - and in such way you can manage it inside your DB or something else - better than a configuration file (it gave me some great ideas for my next posts).
He also used the ServiceHost VIsualizer - I even started to use it at my place.
Next we dive into the Service Model Layer and its behaviors.

I'll probably write about each of them in the near future.
For now, there were 4 demos:

Demo 1: CD - Channel dispatcher - writing you own Error Handler, we also talk about the throttling.
Demo 2: Saving persistence of the Service inside a given Service Host.
Demo 3: DR - Object Pooling using the Dispatcher Runtime, it is a great sample.
Demo 4: Serialization Issues - Eyal wrote a sample-infrastructure for handling Serialization and DeSerialization without using the known-types.

Go Gold with Silverlight (by Laurence Moroney)

This was an Introduction to Silverlight (of course), the only thing I liked about the lecture is the way he explained the differences between Silverlight 1.0 to Silverlight 2, while Silverlight 1.0 - is web friendly UI the Silverlight 2 - is .net based programming model with improve productivity. Laurence showed some cool samples (most of them you can find here, here, here and here), the one I liked the most is a Server servlet (written using J2EE) but the client that consume it is a .net web client (Silverlight) - at my place, one of our teamd, has some Java assets and they want to use it, so they start develop their own UI like in Java for movies\Audio\Web-Parts\Ajax capabilities - this sample could help them a lot.

My grade to the Laurence lecture is 7/10 - Laurence was great the problem was the lecture agenda - I really had enough from the Silverlight previews (so either call it preview\intro or show some code in it)

Restfulness (by Ron Jacobs)
First you should read this book (as they said - this is all you need to know about REST)
After David Chappell's lecture about REST for the first day people told me not to take another REST-lecture, but I did - and - IT WAS GREAT!.
you can read more on Avi's post. Ron gave more details about the implementation of REST using the WCF. for example:
How do you notify the sender about error in REST, you can't send XML back to the client... The answer is simple: for example for deleting non-existing row you will get 404 (HTTP Error code) - I might admit I like this one, the problem is that you should write your own fault architecture to return those codes back, _still_ not implemented at the REST attributes of the WCF. (one more sample: an internal error in your code will probably should return 500 - un-handled exception)
Here is another thing that is still not so easy to do in your WCF implementation - how you can ask for a response? for example you would like to get the JSON return value and not the simple xml... in REST - all you need to do is to add the extension to your request, but you still need to implement it in the WebMethodAttribute by yourself.
And there were more samples, you can download them here... (Ron's website). {you can also read  more in Wortzel's post}
My grade to Ron's lecture is: 9/10.

Monday, April 21, 2008 2:56:16 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] - Trackback
.Net 3.5 | Asp.net MVC | C#3.0 | LINQ

# Wednesday, January 16, 2008

I am not going to explain here nor about MVC neither about the ASP.NET 3.6 (yes it is 3.6, they didn't tell you that?!) I just gonna write a little bit about a sample application I wrote to myself.
Those of you who want to learn more about MVC (the pattern itself) - you can read in Martin Fowler's post or maybe here at wiki anyway there is even a better place to learn this in the Head First - Design Patterns book.
Also you might read about the new asp.net MVC Framework (CTP), you can choose whether to read this (long but very important article) or you can see the intro webcast (damn you lazy programmers)

Microsoft are doing well to cause us work harder just to learn the technology, this asp.net MVC implementation is awesome but It is a huge change for all of you ASP.NET people, I hope I find the time to write more about it, but here is one sample I wrote for myself.


                                       From Request to Response through the MVC Flow

On each request there is a place that the Controller has its constructor calls and this will initiate your logic, I found it very useful to manage this controller creation. In this example I create my own Factory and there I manage to create the controller using another constructor (not the default one), moreover I can also add my own logic such as Security Check (in our sample) or something else useful.

Here is my own Controller Factory logic:

1 public class ShaniControllerFactory : IControllerFactory 2 { 3 #region IControllerFactory Members 4 public bool IsUserExists 5 { 6 get 7 { //Put here your great Logic 8 return false; 9 } 10 } 11 public bool IsUserAuthorizedForEdit 12 { 13 get 14 { //Again Special Logic for Checking Authorization 15 return false; 16 } 17 } 18 19 public IController CreateController(RequestContext context, Type controllerType) 20 { 21 IController controller = null; 22 if (!IsUserExists) 23 { 24 controller = new NotAuthorizedController(); 25 return controller; 26 } 27 28 //Distinct between those two 29 if (!IsUserAuthorizedForEdit) 30 { 31 controller = Activator.CreateInstance(controllerType,(object) false) as IController; 32 } 33 else 34 { 35 controller = Activator.CreateInstance(controllerType, (object)true) as IController; 36 } 37 return controller; 38 } 39 40 #endregion 41 }

You can simply see the CreateController method (lines: 19-38) where I put my logic for the Controls initiation, and I simply prefer creating them using my constructor (the one with the bool parameter) and not using the default one.
But, How will we have this Controller Factory running instead of the generic factory? It is very simple:

1 protected void Application_Start(object sender, EventArgs e) 2 { 3 ControllerBuilder.Current.SetDefaultControllerFactory(typeof(ShaniControllerFactory)); 4 5 RouteTable.Routes.Add(new Route 6 { 7 Url = "[controller]/[action]/[id]", 8 Defaults = new { action = "Index", id = (string)null }, 9 RouteHandler = typeof(ShaniRouteHandler) 10 }); 11 12 RouteTable.Routes.Add(new Route 13 { 14 Url = "Default.aspx", 15 Defaults = new { controller = "Home", action = "Index", id = (string)null }, 16 RouteHandler = typeof(ShaniRouteHandler) 17 }); 18 } 19

You can see at line 3 (within the Global.asax), this is all I had to do for setting my controller factory as the default factory.

You can also think about another good examples on your own, I've found a great post about TDD and Dependency injection with asp.net MVC by Phil Haack - Read the whole post it is a great one, at the end he is creating his own factory for managing the Control creation using Dependency Injection.

Enjoy.

Wednesday, January 16, 2008 12:04:15 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Asp.net MVC

Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Shani Raba
Sign In
Statistics
Total Posts: 145
This Year: 0
This Month: 0
This Week: 0
Comments: 97
Cool Stuff
Add to Technorati Favorites
Themes
Pick a theme:
All Content © 2012, Shani Raba
DasBlog theme 'Business' created by Christoph De Baene (delarou)