Thursday, August 26, 2010

Using Twitter's @anywhere Service on Localhost (and with Web Matrix/IIS Express)

Here is the trick to get Twitter's @anywhere service ( working on your localhost website for development and testing.

1) Don't put a call back url when you register your app.
2) On the link below where you register the call back url for your app, click the add domain link.
3) Add either localhost,, or both (may not take
4) In your javascript specify the callback url (localhost,, whatever. I didn't test this but I think you might even be able to enter ports in (localhost:8080). I ended up setting my web server to run on port 80 (default) so I didn't need to add any ports. If you can't enter ports, you might be stuck having to run your dev web server on port 80 or 8080.

Done. No editing hosts files, nada. Why is this so easy and not documented? I think it is because of a recent change on Twitter's end to loosen things up a bit so you can test your applications. For deployment, you may need to actually enter a call back url for your application. I don't thinks so, but test.

For me I'm working with Web Matrix, and I wanted iis express to run on Port 80. Three things.

1) Turn off/stop your default non-IIS Express web server (apache, dev version of IIS full) so you don't get any conflicts.
2) navigate to where the web matrix exe file is located by opening up a console by typing cmd in the start run menu, then navigate to the path by typing something like cd: c:\mypath\. Once there you can run iis express from the command line (only way right now to specify a port).

type something like iisexpress /path:c\mywebpath\mywebsite\ /port:80

3) Right now you can't have any spaces in the path name. I figure that will be fixed in the next beta or the final release.

Wednesday, August 25, 2010

WebMatrix RendorPage() and Functions: Not Quite Include Files

Out of curiosity, I added a function to a header.cshtml file like so-

@functions {
   int AddTEST(int a, int b)
      return a + b;

Then I tried calling the function in index.cshtml like so-


As I thought, if failed. So, just to keep in mind all you scripters that RenderPage() in WebMatrix is not quiet like include files in PHP or Classic ASP. For functionality that is shared across pages you will need to create a class for that, which is pretty easy to do, but not quiet what you might be used to. Welcome to OOP :)

Sunday, August 22, 2010

Webrazor Newbie Tip: Getting a Record Count

OK, a common task is getting record counts. With WebMatrix, you return a query that actually is a bunch of objects that are IEnumerable. If you are a noob don't worry to much about what they means so much as what it allows you to do.

WebMatrix queries support the new .Net Linq functionality. This allows you to apply Linq operators to your query results which makes it easy to get record counts. Example:

var db = Database.OpenFile("somedb.sdf");
var q1 = "select * from table";


There are a total number of @q1.Count() records in table.


Using Gmail with Webmatrix ASP.Net Web Pages

OK, here is a basic example of how to use Gmail with Razor/WebMatrix ASP.Net web pages, in this case a .cshtml page.

  1. @{  
  2. try {  
  3.         // Initialize Mail helper  
  4.         Mail.SmtpServer = "";  
  5.         Mail.SmtpPort = 587; //25 465; - 25 default, 465 in documentation, 587 works  
  6.         Mail.EnableSsl = true;  
  7.         Mail.UserName = "your user name"// include domain if not gmail  
  8.         Mail.From = "return email address";   
  9.         Mail.Password = "your password";  
  11.         // Send email  
  12.         Mail.Send(to: "target email",   
  13.             subject: "test",  
  14.             body:"yo!"  
  15.         );  
  16.     }  
  17.     catch (Exception ex ) {  
  18.         <text>  
  19.           <b>The email was <em>not</em> sent.</b>  
  20.           The code on the PrcessRequest page must provide the   
  21.           STMP server, user name, password, and email addresses   
  22.           required.  
  23.         </text>  
  24.     }  
  25. }  

Wednesday, August 18, 2010


I love Twitter, I hate Twitter. If you don't get it, well, don't feel lame. Twitter has it's uses, but those uses are not for everyone. As an information gathering tool, a networking tool (as in meeting people with similar interest), and a marketing tool (or a pushing info/viewpoint tool...I'll put that under "marketing) Twitter is an awesome tool that will only get better.

I've had a few people look at my number of followers and ask how I and why I have the numbers that I do. My numbers aren't that impressive, nor does anyone's numbers really need to be high to use Twitter effectively. My numbers do look impressive to friends of mine that are just getting started with Twitter and wonder how to expand their following. I had so many questions about it I finally wrote something down for an indie gamer forum and then later posted that to associated content. The information might be of use to some, if so check it out.

A Simple Eight Point Strategy to Grow Your Twitter Following

Let me know if this helps, or please share any other successful strategies that you have used.

Monday, August 09, 2010

Coding Snobs and WebMatrix

I've had a feeling for a while now that programming is becoming to nerd dominated and fad driven. If you do a Google search on, it will be eye opening just how opinionated these little geeks can be. But if you dig past all their little fo arguments about best practices, the craft of software development, how webmatrix is a step backwards, etc... you begin to reveal that the primary motivator for the geek squad is that tools like the WebMatrix might make Web Development easier, which threatens the geek's elitist geek only club.

I started in Web Development with classic ASP. All the critiques of classic ASP and for that matter PHP leveled by the geek elite are generally accurate (spaghetti code, no separation of concerns, no OOP, hard to test, violating the DRY principle, etc...). But to me at least, it sure seems like I got more web applications out the door back then. Half the time now I'm struggling to keep up with technology rather than solving client problems.

Case in point. I work with an extremely talented developer. He took a stab at Silverlight. It took him about a month to get some even basic concepts like taking data from a user's input and saving it to the database. I was in a similar situation with Silverlight 3 awhile back, where I was using it but decided to stop when I started running into problems doing what I would think are simple things. The datasave models I think are way to complicated. The geeks will stay up 14 hours a day coding to figure things out. I'm fine with that, if IT IS NECESSARY. But I really don't think the pain is necessary, not if Silverlight was being designed for Morts rather than Einsteins and Elvisis (using Microsoft's terminology to describe developers). I don't mind have to stretch and learn new things to get problems solved, but doing basic stuff like data connectivity shouldn't be as hard as it seems to be sometimes, and I think the issues arise because Microsoft for so long has been driven by the elite geek crowd. This is a small crowd, and if Microsoft continues to only target tools at this crowd, Microsoft will go the way of Novell and Lotus Notes.

That being said, I think webmatrix was a great step by Microsoft, unfortunately it is a step that should have been made around 2003. Not only does webmatrix have to lure PHP developers, but it also has to lure people away from Mac's to PC's. That is a tough sell to the growing Mac hipster crowd, and uphill battle. But I give Microsoft props for trying.

Friday, August 06, 2010

Gmail for Business, Home Web Server DNS Services, Transferring Domains

OK, I'm broke. Like seriously broke. So in a cost cutting measure I got rid of my web host and decided to run a web server from home, as this would save me 17 bucks a month. I had an old box, and the software con gratis from Microsoft to do it. So here is what I learned.

  • Anti Virus software for servers is robbery. Very expensive. There are some hacks you can do to make free or low cost desktop AV software work, but it is kind of a pain and is not guarantee of working for long.
  • PC Tools free AV version does work on Windows 2008 R2 Server. Not sure how well, but it installed and did a scan, is free, and is what I ended up using until I make a purchase.
  • If you have a web host that established your domain for you, changing your domain to point somewhere else can be a pain. I would recommend going to the domain hosting service, getting your account all squared away, but don't make any changes yet. Then go back and cancel your web hosting account. I had trouble with one domain because every time I tried to change the name servers, the web host thought I was hijacking the domain name, and somehow they had authority to stop me. I'm still trying to fix that. Overall I think you are better off separating domain names and hosting, as if the two are connected they don't like to separate.
  • There are a few free dynamic DNS hosting services out there. I like and I decided to go with this round, as they were cheaper, and so far they have had great service.
  • Check out Gmail for Business. The standard version allows use of Goggle Aps, up to 50 email addresses each with 7 gigs of space, and was fairly easy to setup up so I could use Gmail seamlessly though my domain, so instead of "" everything is "". Pretty cool.
  • Watch what room you put your server in. My upstairs gets pretty hot in the day, and my server actually locked up and I thought something cooked off. Ended up banging the hard drive a few times with a hammer that was laying near by, shook the fan on the CPU, made a quick prayer, and the server rebooted and hasn't had a issue sense. Prayer works, but don't want to be presumptuous in the future, so I'm moving my server to another room were it is cooler.
  • And lastly, of course, back up. Especially if you are using an older box like me.
That is about all my wisdom so far. Hopefully a few sites I'm working on will get enough traffic to become a problem :), which I will consider a good thing. Then I upgrade the ghetto box and look for a co-location place to drop my server into, or maybe some sort of visualization solution. I think I need more access to my server then shared hosting will allow for what I want to do, we shall see how it goes.

Tuesday, August 03, 2010

Opportunities Lost...Opportunities Gained

Kind of a sad day, I finally cancelled my web hosting account with due to the fact that I am going absolutely broke. If anyone needs a good .Net hosting solution, I would recommend them. At one point their servers were all in Phoenix, I believe they still are but that might have changed after they got bought out by Newtek, but their service has still been great.

I could have done a lot with my hosted accounts, so far none of them panned out. I had great hope for the Apollo Group using, but it was not to be.

Good news is, that I've got a web server up and running for free, and I plan to make good use out of it.