SQL Server 2005 – Troubleshooting Orphaned Users

I always seem to keep forgetting when I backup from one server and restore to a new server that SQL Server 2005 will recreate the users from the original server, and they become ‘orphaned’ as they don’t match to the similarly named user on my system automatically, and thus cause an error when an ASP.Net application tries to use its web.config settings to access the database.

This Microsoft Support article gives the steps needed to fix this orphaned user issue as well as create it in the first place, so this is a cool resource to have when training others on the issues they may face and how to mitigate them when wearing their database administrator hat.

Quick and Dirty ASP.Net on Linux – Ubuntu, Mono and MonoDevelop

Having become inspired by the recent TTLUG activity in finally setting up the new TTLUG website, as the group’s Trustee I found myself ashamed that I did not even have a Linux machine readily available to hack anymore. My work took me so far into the C#, ASP.Net, and now ASP.Net MVC worlds, that I had little time for Linux or Linux-based Open Source software. Thankfully, fate stepped in.

I saw my coworker about to throw away several old IBM T23 Thinkpads. Now if you know and love classic hardware like I do, the words “throw away” and Thinkpad just don’t come in the same sentence, those babies are beasts. I managed to get two of them, and 2 spare batteries.

On bootup at home one of these machine’s hard disks failed while Ubuntu was installing to its hard disk, however the other took the Ubuntu 8.04 CD installation with quite a surprising speed for a lowly Pentium 3 with 256MB RAM. After doing the expected setup without hassles and updating the distribution via the Internet (using a  network cable since there is no built-in wireless in the T23) I rebooted and now had a full Ubuntu desktop system ready to go.

The first thing I was curious to see if I could do was build and run a traditional ASP.Net web page and get it running on Linux. I had tried several years ago and the process was painful and I ended up giving up before I succeeded in resolving all the issues. I was pleasantly surprised then by the *almost* painless experience this time around.

Launching Synaptic Package Manager, a quick search in it for Mono revealed the package I needed to install, and I saw the results also included the package for MonoDevelop, a RAD tool I used in my first experience all those years ago. I instantly clicked on it, not only because I had liked the tool, but because of a rule of thumb I learnt when dealing with smart installation tools like apt and its GUI-frontend Synaptic Package Manager i.e. when not knowing exactly what to install in Linux to get developing with a language, installing an IDE for that language should ensure all the dependency installation packages were also checked.

After clicking apply, and the downloads had installed I ran MonoDevelop, and used the menus to create a new ASP.Net Web Application in C#. A little browsing through the buttons at the top menu revealed the Run button (the one with the cogs), and this is where my first hurdle was hit. The build failed, reporting that “Build failed: Executable not found: /usr/bin/gmcs”. Undaunted, I did a quick Google search for the error, which resulted in a link to this Ubuntu forum thread, which indicated if I installed the package manually it would take care of the issue. Another answer in this thread recommended I also install automake.

After starting a bash Terminal and running the commands

sudo apt-get install mono-gmcs
sudo apt-get install automake

I went back into MonoDevelop and tried to run my web application again. This time the application compiled, however when it tried to run I was hit with an error window stating ‘xsp2 server not found’. Learning immediately from the previous error that it was probably a missing dependency I went back to my Terminal and typed the command

sudo apt-get install xsp2

which installed the xsp2 server and its dependencies. Again in MonoDevelop I clicked Run, and was quite happy to now see my test default page open up in Firefox, with xsp2 hosting it at localhost:8080.

Now that I’m up and running, I’ll probably be browsing the Mono project site a little more often for tips and hacks I can use with my new Ubuntu system using my experience as an ASP.Net developer. Hopefully by the next Ubuntu release someone who knows how to will have fixed the bug that left out these few important files from the present installation and iron out the current kinks in the system.

What is a “Predicate delegate” – bytes

Thinking in terms of Delegates was always a bit of a challenge to me. So when I hit the Predicate parameter when trying to using a List<X>.FindAll(XType y).

The example given in discussion on this article went a long way to clearing this up. If I get more answers like this from Bytes I might start using this as my secondary source of programming answers after StackOverflow.

Customising the debug and run an ASP.NET MVC Application

I tend to use F5 to debug my code, my two teammates have a preference to have the codebase as a virtual directory in IIS and make changes to their code in Visual Studio and then reload the page in a browser to analyse the returned results.

Which is the better technique? Certainly my co-workers had a  point that by running using Cassini instead of IIS I was opening up myself to bugs popping up when the application was deployed to a real IIS box on testing and some IIS-specific behavior arose.

But why must I hassle myself with attaching IIS to the W3wp.exe process every time I want to do a line-by-line debug my code? And I always want to be debugging, especially in this new realm of integrated ASP.Net MVC where debugging a View means you have to worry about if the bug lies in your ASP.Net code, your JQuery code, or the service(s) your .ajax or .getJSON calls are making. I didn’t mind the hassle of having to recompile every time a change needed to be made inside the Controller or Business Logic layers once it meant I could track the state of my application during events as closely as possible.

Turns out we can have it both ways. These recommendation from Stephen Walter, although set on the topic of running an ASP.Net MVC Application specifically, are useful for any developer looking to customise the debug and run process when using Visual Studio 2008. So my coworkers and I will both be happy, because now they’ll be readily able to debug their code in real time (and engaging in a better coding practice at the same time) and I’ll be running my debug sessions on top of IIS to remove any possible hiccups from using Cassini for testing.

The settings are available on the Web tab on the Web Application Project’s properties page (ASP.Net MVC or not)  and to do this I have to make sure it is set to use a local IIS virtual directory (which I’ll make right there if it isn’t set already) and that I enable the check box that allows me to make code changes without the need to stop debugging and recompile.

Getting the address of the hosting server

One of the simple problems I’ve encountered was just getting the name of the server that’s running my ASPX application, whether it be the localhost:xxxx of VS 2008’s Cassini server, localhost, or http://www.myserver.com. The following commend returns that as a string.

Html.Encode(HttpContext.Current.Request.ServerVariables[“HTTP_HOST”]

The ServerVariables NameValueCollection has a very interesting collection of information that I can see being quite useful to know about in future.

DotNetJunkies has a good tutorial on ServerVariables in ASP.Net.

Note: The command above only returns the address as a string, not the protocol. If you want to use it in an anchor tag (<a href=”someaddress”>somelink</a>) don’t forget to append the protocol (e.g. ‘http://&#8217;) to the string returned from the command or you may experience some strange behaviors.

RestrictedFormats/BluRayAndHDDVD – Community Ubuntu Documentation

While trying to put together an opinion blog article for The Redditech Blog I came across this informative post for Linux lovers on RestrictedFormats/BluRay And HDDVD  from the Community Ubuntu Documentation which basically gives guidance on using High capacity optical drives within this operating system. Enjoy!

How to configure for no-www : The Official Microsoft IIS Site

I’m taking note of this link on how to configure for no-www from  The Official Microsoft IIS Site. It took a bit of Google searching to find, although it was really easy to find how to do the same task using an Apache web server (use rewrite rules for .htaccess ).