Browser history 3–trying to Nuget

This is the part 3 of 5 of my implementing of a MVC Browser history

MVC browser history – idea

Browser history –2 – implementing, small bugs

Browser history 3–trying to Nuget – modifications in order to can be transformed from an application to a component

Browser history 4–NuGet again – finally Nuget deployment

Browser history–part 5–conclusions – conclusions

TL;DR : Trying to add a feature (NuGET ) will conduce you to other features – apparently easy to implement – but took 2 hours…




First, source control is more important – .I choose github  – deploy is a breeze with GitHub for windows . More, appharbor integration with github is awesome – you can see the application live at .


Now , for generating Nuget package, I should be moving the classes on their own assembly / dll. Also , added this blog to the info. Ensure it works the same. Uploaded to GitHub


And appharbor just deployed



Now, it will be good if I let user switch implementation between memory saving  and database saving… in order to developers( that have installed the dll with  NuGet  ) switch easily to their database.



and , after some implementing of IBrowserUserHistoryRepository , the method

public IBrowserUserHistoryRepository FilterByUser(string UserName)

put some problems – but solved with a private variable.


Now must decide the best way to switch between MemoryRepository and SqlServerRepository in

public static T AddOrRetrieveFromApplication<T>(HttpApplicationStateBase app)
where T:new()

First, we must retrieve at runtime the instance of the interface – so structuremap to the rescure.

Second, if we need to retrieve a class – must have at least a default constructor.

So the constraint of the T was gone away   – and the code is

T result;

if (typeof(T).IsInterface) {

result =(T) ObjectFactory.GetInstance(type) ;




result = (T)Activator.CreateInstance(type);


Also, in global.asax the following lines were added:

//ObjectFactory.Configure(ce => ce.For<IBrowserUserHistoryRepository>().Use<BrowserUserHistoryRepositoryMemory>());             //uncomment those for sql server ce             ObjectFactory.Configure(ce => ce.For<IBrowserUserHistoryRepository>().Use<BrowserUserHistoryRepositorySqlServer>());

Now, when deploy , AppHarbor will NOT found EntityFramework dll.

Added HintPath to csproj to find EF

as seen at

and it works!

More, it works with sql server AppHarbor addon  and transformation of web.config.


It took 2 hours to do this thing, apparently simple.
Now you can find the code source on github at
You can browse the application at

Next time: (maybe some tests and ) NuGET!