An Example Of The Need To Use Absolute URLs
I have been doing some work around twitter and ASP.NET MVC. The way twitter authentication works, is that I have a page that creates a twitter URL, redirects the user to twitter,
the users accepts to use the application associated with the website, and twitter redirects the user to a callback URL, the completes processing of the user credentials. In order to set a callback URL dynamically (especially in development, when the callback is likely a localhost one), we need to send the absolute URL to twitter.
Other examples might include having a “permanent URL” for some resource (product, blog post, etc..), or maybe a link to be used in emails or so. There can be many usages, so, let’s see how to do it!
How We Did It In Webforms
In webforms, the easiest way to do it was to use the Control.ResolveClientUrl() method.
Typically you pass a URL relative to the current code file (.aspx, .master or .ascx file). and it returns the corresponding absolute URL of that. Of course when the file is a control or a master page file, we don’t always want/have a path relative to this file. The work around for this was passing a relative URL that starts with “~/”. As you probably know, “~/” represents the root of the website.
Read the full post ... (584 words, 3 images, estimated 2:20 mins reading time)
.NET FAQ, ASP.NET, ASP.NET Controls, ASP.NET MVC
If you downloaded Visual Studio 11 Beta, and tried to create a new ASP.NET MVC 4 empty project, looking at the “Scripts” folder, you’ll see this new file “_references.js”:

Which looks like the following:
/// <reference path="jquery-1.6.2.js" />
/// <reference path="jquery-ui-1.8.11.js" />
/// <reference path="jquery.validate.js" />
/// <reference path="knockout-2.0.0.debug.js" />
/// <reference path="modernizr-2.0.6-development-only.js" />
The VS <reference /> Syntax
As you probably know, the `// <reference path=”…” />` syntax was introduced in Visual Studio long time ago to make you able to have intellisense in any JavaScript file to include everything defined in the JavaScript located at this path.
In easier words, if you write the very first line in any JavaScript file, say “my-page.js”, and make sure the path points to the proper jQuery file, when you write code in “my-page.js”, you’ll get intellisense for everything in the jQuery file. The quality of the intellisense will vary based on the referenced jQuery file, whether it’s minified file (least intellisense info, only member names, sometimes), just standard source/debug file, or even one that VsDoc comments (best intellisense, might even have notes on what types you need to pass to methods, when defined in VsDoc comments).
Read the full post ... (621 words, 4 images, estimated 2:29 mins reading time)
.NET, .NET FAQ, jQuery, Resharper (R#), Visual Studio 11, Web 2.0
This morning I got a nice little email from a dear Egyptian friend, Ebeid Soliman (@ebeid_soliman) asking the following:
I know this may be something answered by google, but I trust your opinion.
What is the best free automated UI testing framework/tool you used ? or know ?
I actually already have a long draft on the subject showing the framework I use, and how to get basic stuff working on it, since this one is not yet complete, let me for now share my reply to him with you, as raw as possible …
(I have added some titles to make the long reply more readable)
The Reply
Choosing a framework
Look, I haven’t tried many. Only Watin and Selenium, and even Watin didn’t dig it enough.
The people around me all seem to be using Selenium. This is not only the story though…
Read the full post ... (980 words, 2 images, estimated 3:55 mins reading time)
.NET, .NET FAQ, ALT.NET, ASP.NET, Selenium, UI Testing
Introduction
Sqlite
SQLite is a file based database, or an embedded database that you can use without need for any special installation from your side. It’s a bit popular for non-LOB (line of business) desktop applications and even mobile applications like Android apps. It also has an "In-Memory" mode where there is no physical file used as a database, which is usually used in testing.
It has a similar syntax (sort of) to SQL Server. In Microsoft .NET world,, those using NHibernate are usually using the in-memory mode for applying unit testing or trying out NHibernate stuff, although Microsoft has its own embedded database called SQL Compact Edition (CE), which doesn’t seem to support in-memory databases (v4.0).
You can download the latest Sqlite database (v3.0) from:
http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
Since it’s not SQL Server, you need a special ADO.NET provider too. It’s called "System.Data.Sqlite"., which is very similar to the normal System.Data.SqlClient stuff. It’s included in the above download link.
NuGet
If you don’t know what NuGet is, go to www.nuget.org or check my old posts mentioning it, or if you are an Arab maybe check this post in Arabic.
Read the full post ... (1374 words, 7 images, estimated 5:30 mins reading time)
.NET, .NET FAQ, Miscellaneous, NHibernate, ORM
Lately I have been doing more stuff on the Console as getting to Ruby and messing a bit with Git and stuff.
Generally speaking the default Windows Command Prompt is really fine for my needs, but I sure would love to see more possibilities. PowerShell was a great scripting / tooling addition but not much of “Editor” / “Environment” improvement. PowerShell ISE (integrated Scripting Environment) is really so nice and powerful, but it doesn’t feel exactly like my usual Console. I tried Console2 and was really impressed with how similar and different it is in the same time.
Surely, it didn’t mean I have to lose PowerShell features in there!
Get Console2
Just grab it from http://sourceforge.net/projects/console/files/console-devel/.
By the time of writing v 2.0 was the latest. I just went to that folder and got the latest Zip in there. Yeah. No install, just a Zip file, so, you may need to make a shortcut for it on your own and / or place it in somewhere that’s already in your Windows ENVIRONMENT variables.
Find the Path To PowerShell
The way I did it was go to Start menu, type in PowerShell in the search box, and right click the PowerShell icon, and choose Properties.
Read the full post ... (329 words, 7 images, estimated 1:19 mins reading time)
.NET, .NET FAQ, Office Productivity, Ruby