Monday, September 13, 2010

Hosting a website at home using IIS 7.5

I wanted to try out hosting a website through Windows 7 (IIS 7.5) (steps would be pretty much the same for windows 2003 and 2008.

The purpose of this is to host your web server at home, for me this is used for Demo purposes or debugging internet based apps that would later be hosted somewhere else.
(other things you could host would be TFS servers, FTP servers etc.)


First would be to register at a DDNS site like www.no-ip.com or www.dyndns.com (for the purpose of this tutorial I'll be using www.no-ip.com).

Now, login to the site and Click on "Manage Hosts",








"Add Host"




















Under Hostname would be your site name, this would become your URL like for this demo would be MySite.zapto.org

IP Address would be auto populated but if not it would be the IP Address your ISP provided you with. in my case having a dynamic IP based DSL Connection, my modem every time it restarts would change it's IP address. (no-ip has a downloadable tool to manage this automatically DDNS Update Client.

click on "Create Host" and we're done.


Second would be to installing IIS on Windows 7.

1. Click Start and then click Control Panel.
2. In Control Panel, click Programs and then click Turn Windows features on or off.
3. In the Windows Features dialog box, click Internet Information Services and then click OK.


Third would be Setting up your site.
1. Run IIS Manager in the start menu and type "IIS"
2. Add a new "Web Site"
3. Enter a Site name like "MySite" or your project name
4. Physical path is the location of the site on your hdd like in my case would be (D:\Sites\Demo\MySite)
5. Host name would be the URL you created at no-ip.com (ex. MySite.zapto.org)

Fourth would be to setup your Windows Firewall to accept Inbound and Outbound traffic for your site. (if you have other firewalls like Norton or Zone Alarm, you'll have to give access to your ports as well).

1. Click the Start Menu and run "firewall"
2. Click Windows Firewall with Advanced Settings.
3. Click Inbound Rules and make a new rule.
4. Start the "New Rule Wizard"
5. Click Port and enter "TCP" and port "80" then click Next
6. Allow the connection then click "Next"
7. Click the rules that apply, then 'Next' (everything is selected)
8. Name the New rule like "WebSite Inbound Rule" and click Finish.
9. Check if the rule has been created and active and then close the firewall.

Fifth would be to setting up your router to allow connections for port 80 to pass through, now depending on your router this can be a bit tricky but the rule of thumb is.

If your router has a firewall, give Inbound access to port 80.
and lastly make sure to port forward port 80 to your server.

If you have trouble port forwarding depending on your router model, this site has been very helpful to me in the past. (www.portforward.com)

Theoretically this should be finished however on my setup when I tried to access my site it went directly to my modem's Web based Config page.

my setup currently is Internet > Modem > Router > Desktops and Laptops.
now, this won't work properly with my modem blocking the connection, so the solution is to "Bridge" my modem to my router making my router as the PPPoe dialer instead of my modem. (again how to go about this depends on your ISP, model of your modem and router).


Enjoy!

Wednesday, July 7, 2010

On using NDepend

I was recently introduced to try out NDepend which is a Visual Studio add in and pretty much
a code metric and code quality tool to manage complex .net projects / solutions.

After a painless download and install I fired up visual studio 2008, loaded up my template project for a web application, did an analysis and was greeted with an html file with all kinds of reports.

at first it was a bit overwhelming but upon reading the report I was surprised at the information it had about my project.

One of the first things that got my attention was the "Assemblies Metrics", this pretty much tells me how abstract my assemblies are, lines of code, lines of comments, coupling and cohesion. just by having this and running it on every build or release would show how my project is growing and where it's headed.





Next is the Assemblies Abstractness Vs. Instability.
(explaining the chart is another topic altogether but for a primer this document explains it pretty well)

but the main point of the graph are

Abstraction where it would show how extendable your assembly or code is.

Stability where it would explain how dependent your code is to other assemblies or components, this doesn't mean that the

higher the instability the more unstable your code will be but rather how dependent your code is to other assemblies, (more dependent it is the harder it is to change your code.)

if the assembly is not that extensible the more it will go to the zone of pain (this would be pretty normal on end points like web services and wcf services, where it's usual that there would be no virtual methods or abstraction).

the zone of uselessness would show that if your class is too abstract and no other classes depends on it then it goes there.



Assemblies Dependencies Diagram I can't stress enough how many times this could have saved time on my previous projects where a visual diagram would show
class heirarchy and dependencies.








Running up Visual NDepend provides you with the CQL Queries (Code query language), this uses the same syntax as SQL but uses your code base as the database and right now the default code quality metrics NDepend has seems to cover everything I would need to be able to refactor my project properly.

things like Unused codes / dead codes, code quality, naming conventions and Encapsulation are queried, now other products also does this like resharper / FXCop but I like the extensibility NDepend offers. although I'm a bit half hearted on this one since I like how resharper presents the code errors and optimizations while I'm coding, NDepend seems to target more the team lead / architect level where code reviews are done and evaluated.


so far I've only been playing around with this tool for a couple of days and it is quite impressive, This is the kind of tool I would recommend to a company with large projects and solutions where managing source code becomes more and more "challenging" as it grows.

There's a Trial / Open Source / Academic Edition and you could buy the Professional Edition for about US$ 377, the more licenses the bigger the discount (although I'd assume you'd only need 1-2 licenses per project in a company.)

you could also check out their site for tutorials and videos about the product.

Saturday, July 3, 2010

Sharepoint 2010 problems for old MOSS developers?

My biggest problem with Sharepoint 2010 right now is it killed the standalone developer support that does not have a killer machine.

On MOSS 2007 I was used to running a VM network on my laptop (or dekstop server) with Moss 2007 on one VM, Domain server on another VM and my dev environment on a 3rd VM (sometimes this is reserved for an ISA server or Biztalk depending on the requirements).

This makes sure I could develop and debug my applications without being connected to a dev server, as well as making sure that if i ever screwed up my VM I could just plug in another one from my backups.

Sharepoint 2k10 now killed this concept with the requirements of having SQL Server 64bit and Windows 2008 Server r2 64bit.

since most mid range laptops are running on 32bit OS and VMWare / Virtual PC doesn't support CPU virtualization, I'll be stuck with SPS2k10 running on my dekstop and my dev environment running on my laptop for now.

you could also use this tool to check if your laptop could support 64 bit VM

for now... I'll postpone migrating my environments until I could properly backup my laptop and change it from Windows 7 32 bit to 64 bit (and download all the requirements which with the problems I'm getting from my ISP could probably take me 3 years to finish.)

I also wonder...how painful would it be to migrate my web parts, custom controls and Portal. Hope it's not as painful as migrating from 2003 to Moss :P

Tuesday, June 8, 2010

Tools I can't live without...

Every developer has his/her set of "making my day to day life easier" in the workplace.

Most in this list are free while the rest has 30 day trials you could download from their site.

I'll go in depth on how to use each one in the weeks to come, but for now a short description and links.

Resharper -
This for me makes coding a whole lot easier with real time compiler error notifications, Code refactorings, Safe Deletes, Safe Renames, a more robust "Find" function, Code Analysis and my favorite. Unit testing and integration with dotTrace Profiler.


Fiddler
-

I Can't remember how many times this small free app has saved me days of debugging hell, pretty much this app acts as a proxy capturing all http "REQUESTS" from your browser as well as capturing all "HTTP RESPONSE" that you will get from the web server you're requesting from.

it will provide various information that isn't normally seen like, file sizes, html raw formats, request hops, cookie information, XML.

if you're doing custom Requests to a web server or sending unusual POST messages. this is the tool that will make things a whole lot faster.


Notepad++
-
This is what the standard notepad of windows should have been, Text Compares, spell check, text compare, XML formatting, HTML cleanup, Tabbed interface.


SandCastle
-
Making inline comments, XML code comments into a generated help file or set of html files, code documentation just got easier. to top it off it's free!

Red-Gate SQL
-
Red-Gate's SQL Toolbelt is the one stop tool for database control, with tools like SQL Compare (table, Stored procs, views etc).

SQL data compare.

Data Generator (with customizable rules).

SQL Doc - ever had problems remembering who last modified that table or stored proc? or what it was a month ago?, fast and easy to use database documentation is the answer.

and my personal favorite SQL Prompt - integrates with your management studio and provides a much needed intellisense, auto complete and refactoring.


FireBug (firefox addon) - Simply the best javascript debugger out there, view your DOM, add breakpoints, notifies you of errors you never thought were there.

iMacros - Ever had one of those web apps where you have to go through steps 1 - 5 to be able to debug step 6? this firefox addon captures all your http requests and response to get you to step 6 with a click of a button.


Hope you enjoyed this post as much as I did writing it. I'll go in depth with these tools in the coming weeks to come.