Tuesday, November 20, 2007

Regurgitated News: VS 2008 / .NET 3.5 RTM'd


I wonder how much longer my beta will operate.  Hopefully it won't self destruct like my Office 2007 beta did. 

<ramblings type='bedtime' >

Man, had to think a bit to come up with that number (2007).  The electronics industry as a whole needs to come up with some sort of generational labeling standard for software release, video game consoles, etc.  I do like the "year" naming method VS 2.0, 2.5, 3.0, etc.  Not only does the year naming convention increase in size with newer product versions, but it gives consumers some details about when it was released, and how old it is now (assuming the consumer knows what year it is).  Maybe it could go in cycles, like presidential elections.  So we would have

  • Visual Studio 2004
  • Xbox 2004
  • Nintendo 2004
  • Disc 2004 (instead of DVD)

and then the next generation would be

  • Visual Studio 2008
  • Xbox 2008
  • Nintendo 2008
  • Disc 2008 (instead of Blu-ray / HD-dvd)

Hmm... those names suck from a marketing standpoint.  Then again, that never stopped Microsoft.


Monday, October 29, 2007

File Upload not Working on First PostBack after loading Async through ASP.NET UpdatePanel

I was setting up a ASP.NET Wizard control.  The 3rd or 4th step had a file upload control on it, with a runat="server".  The entire wizard control I wrapped in an ASP.NET UpdatePanel so that the wizard was all AJAXified.  I had already fixed the "next" button for this wizard step so that it did a full postback to the server, not an asynchronous one - since I knew that was required to get a file upload to the server.  However, the file was STILL not being posted back, atleast not on the first post.  Subsequent posts would work fine.  On a whim, I looked at the Firebug console to inspect the details of the request while it was in progress (Set a breakpoint in your code somewhere, then look at the Firebug console -- you'll see a "POST" entry with info about what was posted, headers for the request, etc).  Below the POST entry, I saw a warning/error message I had never seen before:

 This page has a file upload.  However, the form tag does not have both the enctype=multipart/form-data and method=POST attributes.  The file will not be uploaded.

Hmm...  I thought about it a bit, and then looked at a normal page I had that had file upload controls on it.  Sure enough, the form tag (there is always just one in ASP.NET) had the enctype attribute set automagically by ASP.NET if ASP.NET knew there was a file upload control on the page.  Otherwise, it leaves it off.  The Async update by the UpdatePanel was loading the FileUpload ok, but wasn't adding the enctype=multipart/form-data to the form tag attributes. 

Solution: manually add the enctype to the page's form on Page_Load()

Page.Form.Attributes.Add("enctype", "multipart/form-data");

Technorati Tags: , ,

Friday, October 12, 2007

SubSonic Central Database Issues

I like using the SubSonicCentral autoscaffold for playing around with my database. I realize that since I'm already in VS2008, often writing stored procedures in the database, I could just use Visual Studio's built in table data editor for this, but I like how the subsonic scaffold (and the autoscaffold) use the interface to make it easier to select Foreign Key columns, dates, etc. Also, the Visual Studio data editor has a tendency to make a "ghost' image of itself if I let a tooltip come up over any cell in the table, and then plunge my PC into a BSOD.

But one day recently, my SSC on my development PC just stopped working. I would get an error in App_Code\builder.abp (which signifies it is a Subsonic/Database issue) stating "Login failed for user ADAM-IMS\ASPNET". I tried resetting everything (IIS, SQL Express Server, Windows XP!) and still got this message, which cropped up randomly. I made sure EVERY Subsonic configuration was correct, and that the connection strings were correct. I made sure the databases (both my development one and Northwind, which SSC requires for some stuff) were set up with proper permissions for user ASPNET on my machine.

I finally solved the problem days later with a random, hopeless (in my opinion) act. I deleted my "ssc" virtual directory form IIS and remade it, then reset IIS. Ta-da! It started working perfectly again. I doubt this will help anyone else, but just in case I forget I'm posting it here.

UPDATE (8/1/2008): I figured out the problem with the Blue Screen of Death showing up when looking at tables in Visual Studio. Finally did the right google search and came up with this: http://botsikas.blogspot.com/2007/06/ssms-and-win32ksys-blue-screen.html.
Thanks to Andreas Botsikas for figuring this out!

Technorati Tags: , ,

Thursday, October 04, 2007

Setup ddclient for DynDNS and OpenDNS

After googling around a bit, and looking at different examples, I came up with a configuration for ddclient that updates both my companies DynDNS host (which I use to get access to certain intranet stuff from home) and the OpenDNS Dynamic IP address, so OpenDNS can collect stats and customize our experience, etc.  Leave a comment if you need something explained or need more info on how I set ddclient up.  (Note: Values surrounded with [brackets] are names changed to protect the innocent :-)

# Configuration file for ddclient
# /etc/ddclient.conf

daemon=300 # check every 300 seconds
syslog=yes # log update msgs to syslog

### Select one of these options to determine your IP address
## via hardware interface (if you don't have a router/firewall)
#use=if, if=eth0
## via our CheckIP server

use=web, web=checkip.dyndns.com/, web-skip='Current IP Address: '

## from the status page for a linksys router/firewall
#use=linksys, fw=linksys, fw-login=admin, fw-p

#DynDNS for [dyndns_host_name, e.g. bob.ath.cx or bob.dyndns.org]
[dyndns_host_name], [dyndns_host_name_2]

#Dynamic IP for [OPENDNS_NETWORK_NAME] OpenDNS account


Technorati Tags: , , ,

Tuesday, October 02, 2007

Self-signed SSL Certificate on Development PC

As I near deployment of a moderately large-scale ASP.NET 2.0 web application, I'm trying to wrap my head completely around all of the issues related to deployment.  One of the questions that keeps boiling up in my mind is how an ASP.NET web application, some of the AJAX stuff, IIS, and SSL all play nice together.

After doing some research online, and even asking some guys that run web sites for a living, I've come to the conclusion that this is definitely something that is best learned by doing.  So, I'm going to attempt to setup the whole package on my development machine.  I know enough about SSL to know that this won't be a perfect simulation.  I'm going to try to generate my own certificate, so I'll just have to pretend like I don't see Firefox telling me that the certificate is not from a trusted source or whatever - if I manage to get that far.  Here goes.

The Self-Signed Certificate

When searching for a method to make my own certificate, a couple of methods were commonly suggested on forums and blog articles:

  • SelfSSL - part of the IIS Resource Kit
  • MakeCert - seems to be bundled with Visual Studio
  • MS Certificate Authority.

I decided to try SelfSSL, since it seems to be the easiest at first glance.  So, I downloaded and installed the IIS Resource Kit (which claims to be for IIS 6.0, but people ay it works fine on Windows XP / IIS 5.1).  I did a custom install and only installed the IIS 6.0 Tools Documentation, SelfSSL, TinyGet, Web Capacity Analysis Tool, and WFetch.  The other stuff sounded useful, but I'll probably just forget about it and only use SelfSSL.

After the install finishes, running SelfSSL from the start menu will bring up a command box with the following info and prompt:

Microsoft (R) SelfSSL Version 1.0
Copyright (C) 2003 Microsoft Corporation. All rights reserved.

Installs self-signed SSL certificate into IIS.
SELFSSL [/T] [/N:cn] [/K:key size] [/S:site id] [/P:port]

/T               Adds the self-signed certificate to "Trusted Certificates"
                 list. The local browser will trust the self-signed certificate
                 if this flag is specified.
/N:cn            Specifies the common name of the certificate. The computer
                 name is used if not specified.
/K:key size      Specifies the key length. Default is 1024.
/V:validity days Specifies the validity of the certificate. Default is 7 days.
/S:site id       Specifies the id of the site. Default is 1 (Default Site).
/P:port          Specifies the SSL port. Default is 443.
/Q               Quiet mode. You will not be prompted when SSL settings are

The default behaviour is equivalent with:

selfssl.exe /N:CN=ADAM-IMS /K:1024 /V:7 /S:1 /P:443

C:\Program Files\IIS Resources\SelfSSL>

I decided to be gutsy and try it with all default settings - except to set the validity to 30 days instead of 7.

> selfssl.exe /V:30
> iisreset

Cool beans.  Now, if I look at the "Directory Security" tab in IIS for my default web site (or any of the site under that for that matter) I can click "View Certificate" and see the self-signed certificate I've installed.  There are some errors displayed about it not being from a Trusted Certificate Authority, but I expected that since I made it myself, and didn't get it from a CA like GeoTrust or Thawte or GoDaddy.

I'll try going to https://localhost now - I have just a dummy page set up there in the Default Site.  Ok - two warning dialogs popup.  The first, as I expected, told me that the certificate is not signed by a trusted CA.  The second warns me that the certificate is for ADAM-IMS, but I am viewing localhost.  I want to fix this second one, since Visual Studio usually opens up to localhost when debugging a web application.

> selfssl.exe /N:CN=localhost /V:30
> iisreset

There, that did the trick.  Now I just get the first warning.

Testing the App

Cassini, aka the Visual Studio Development Server, does not currently support SSL (and I doubt it will anytime soon).  Makes sense - it basically opens up a standard http server on a single port (usually 49587 or something like that).  SSL typically runs on port 443 of IIS, separate from the standard http server typically on port 80.  That is why most browsers go to port 80 automatically for http:// and go to port 443 automatically for https:// - of course, Microsoft could write Cassini to support SSL, and make some new convention for what ports are what on Cassini, but I don't think they will anytime soon since you can specify in your project settings that you want to debug your web application using IIS anyhow.  Cassini is for convenience, but you are getting in pretty deep by the time you are thinking about SSL.

So, I set my web app to run on IIS (at localhost/<project_name> for the application root) and fired it up.  Currently, I have to manually switch from http:// to https://, but I'll probably have my Master Page and login page redirect to https:// if a user attempts to connect insecurely.

Things went better than I expected when floating around my application, testing stuff and watching for popup warnings like "This page has encrypted and un-encrypted elements... do you want to display the un-encryted stuff?" I have tried to keep the eventual conversion to secure application in mind, and always follow these conventions:

  • When linking to an image, or another page in the web app, I always use either relative urls [e.g. "img/first.png"] or the ASP.NET application relative path [e.g. "~/dynamics/dynamics.aspx" or
  • I always use relative paths in CSS url("...") values

To be continued?

I'll keep messing around with this, and see if anything else pops up.

Useful things I came across in researching this:

blog.coryisakson.com - MakeCert, and redirecting to https://
Scott Guthrie: Enabling SSL on IIS 7.0 using Self-Signed Certificates - incase you have IIS 7.0, things look much easier
Rob Conery: SSL and Development - SelfSSL, by a guy whose blog I read regularly. Odd and cool that his blog would have this tucked away in the archives. 

Thursday, September 27, 2007

Personal Blog started

None of my immediate family have ever read this blog - not that a whole lot of other people do -  which is fine since this blog is mostly for me.  For instance, seems every time I need to do something at work with Linux and drive imaging I can't remember the EXACT syntax, and it's a somewhat risky operation, so I come here and click the "image" tag to find the post where I wrote that down.

So, I thought it might be cool to start a blog that maybe my mom or my brother would be able to read, and maybe my other readers (Jonah ;-) could actually enjoy.


I started it on wordpress.com, just so I could see what that software is like compared to Bloggers.  So far, I like most everything just a little better, except the custom CSS -- on wordpress they charge you $15/year to have custom CSS!  Seems to me that most people who would even consider editing their stylesheet probably are hosting their own wordpress blog on their own server anyhow, so not sure they'll get a lot of people with that (says me - who wants to muddle with the CSS and not host offsite).  Well, at least they didn't charge me to make the cool custom header.

Friday, September 21, 2007

A test of the Mail-to-Blog function

In the blog setting on Blogger.com blogs, you can go to Settings --> Email, and setup an email account for emailing posts to your blog.  This post was done by emailing <username>.<secret>@blogger.com, which is cool.  The way you set this up sort of reminds me of spamgourmet.com for some reason.  It's neat to see inventive uses of email.

Monday, September 10, 2007

Extending a SubSonic Generated Class

I kept running into this issue, so I finally wrote up a little theory code to see what was possible, and what might be an elegant solution.

The issue: I am returning one of my SubSonic objects through a stored procedure. Normally, pretty straight forward. My test object for this was called "TestTable", and represents the same-named table in the database.

Column Name Type
TestID int
TestName varchar(50)
TestValue int

So, Subsonic generates a class that has all the properties representing these columns, and all the useful ActiveRecord methods.

Now, I make a stored procedure to get elements of this type from the database - normally I'd skip using a stored procedure unless I needed to do some special filtering or business logic, but for the sake of testing / demonstration:

-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.

-- Insert statements for procedure here
SELECT TestTable.*,
CAST((CASE WHEN TestTable.TestValue > 2 THEN 1 ELSE 0 END) AS BIT) AS GreaterThanTwo
FROM TestTable


If you look at the SP, you'll see where things start to get interesting. Not only am I returning all of the columns that exist in our Table (or this could be a View too, same theory applies), but I am also returning an extra BIT field. Here, I'm just setting it to true if the number is greater than 2, but you can use your imagination for how this might be useful. Examples might be returning true if an item is editable by the user viewing it or returning some sort of derived field (a SUM total, MIN, MAX, etc.). When Subsonic loads the DataReader object you pull from this SP in code, it will simply ignore the fact that the Reader has a "GreaterThanTwo" field -- Subsonic uses the Table schema only when pulling the columns from the reader.

So, let's add an extra property to our TestTable generated class, and then make sure that, if present, this information is pulled from the IDataReader.

 using System;

namespace Protos

public partial class TestTable
public bool GreaterThanTwo { get; set; }

public override void Load(System.Data.IDataReader rdr)
if (rdr.FieldCount > TestTable.Schema.Columns.Count)
GreaterThanTwo =
(bool)(rdr["GreaterThanTwo"] ?? false);
catch (Exception)
GreaterThanTwo =


You'll notice that the conditional, and the try-catch block set the GreaterThanTwo property to false if it isn't present in the IDataReader. You could modify this to set it to null by making the property nullable (bool?).


Here are two gridviews loaded up with some sample data. The first one uses the Stored procedure shown above. The second one is a simple Subsonic collection Load(), which will not use the stored procedure or extra column, but does internally make a call to TestTable.Load(IDataReader rdr).


You could also extend this to loading DataRows and DataTables by overriding those methods (e.g. public override void Load(System.Data.DataRow dr)). That should be even simpler, since the DataSet classes seem to offer more information about what is in them compared to the IDataReader (which I gather is swifter, and has less overhead).

Thursday, August 23, 2007

Firefox Slowness with Cassini (VS Web Server) on Vista or XP with IPv6

I'm not sure what happened, maybe a firefox update or maybe the switch to VS 2008 Beta 2, but recently I have noticed that Firefox will take literally 1 whole second to download each and every script, stylesheet, image, etc, from the Cassini web server when I'm debugging ASP.NET stuff on my local machine.  Really annoying, and a waste of time.

So, suspecting it had something to do with a bug in VS 2008 cassini I googled "visual studio 2008 cassini" and came up with Dan Wahlin's blog post about what was causing this (thorugh Mike Ormunds post).

From Dan's blog:


It turns out that the slowness is caused by an IPv6 issue with DNS and can easily be resolved by turning IPv6 support off in Firefox while doing localhost testing.  To make the change, type about:config in the address bar, locate the network.dns.disableIPv6 setting and double-click on it to set it to true.  This does the trick for the Firefox localhost issue on Vista and everything is running fast again.

Monday, August 13, 2007

VS 2008 Beta 2 Quirks Log

I finally bit the bullet and installed Visual Studio 2008 Pro Beta 2 on my development PC.  Couldn't resist anymore with all the buzz in the ASP.NET blogosphere and I thought it would be safe enough since

  • You can install it alongside VS 2005 (in theory - it is a beta)
  • With VS2008 "Multi-Targeting" you can use VS2008 to work on ("target") a ASP.NET 2.0 web application, even using ASP.NET AJAX 1.0 extensions.  Supposedly, you can still get most of the cool features of VS2008 to work while targeting .NET 2.0.

Well, the install went smooth enough for me, but I've had a heck of a time actually using any of the new features I should be able to use.  I mean, the big feature list goes: Multi-Targeting Support, Web Designer CSS intellisense support, Javascript Intellisense, Javascript Debugging, and all the LINQ stuff.  Notice I underlined the features I was personally interested in utilizing on my current project.  Multi-targeting support was the only thing I have had great success with so far.  :-(

Javascript Intellisense

I did manage to get Javascript Intellisense working the way I think it should.  I was using the AJAX Control Toolkit version of the ScriptManager control <ajaxControlToolkit:ToolkitScriptManager> and VS2008 wasn't picking up on this to give me stuff like "$get" and "Sys.Browser" in my javascript intellisense.  Temporary workaround: replace it with a standard ScriptManager.  I was only using the ToolkitScriptManager for its CombineScripts attribute, which lets you combine all the toolkit scripts to be sent to a page into one super script automagically (which I'm still not convinced is so great, not knowing much about how or if browsers cache javascript files generated by ASP.NET AJAX).

<asp:ScriptManager ID="sman" runat="server">
       <asp:ScriptReference Path="~/scripts/protos.js" />

I'll update this post if I figure anything else out along the way.  I really should be getting a paycheck from Microsoft.  :-)  But then, that is the brilliance of the community driven development that Microsoft is tapping into so heavily now - and I can't be angry at them for that, since I have benefited from that a lot more than I have contributed.

CSS Features

I got CSS intellisense almost completely working.  I was using a declaration in the System.Web.Pages section of my Web.Config to bring in the App_Theme\default information from my project, including default.css; this was not working for the CSS features.  I had to create a manual <link rel="stylesheet" /> in the <head> of my master page, and then it started working slowly but surely.  Another thing I'll have to remember on deployment.  Good thing I have this all written down somewhere.  :-) 

The one thing that doesn't work is typing class="   doesn't bring up an intellisense box like it is supposed to when a StyleSheet and classes are present for a page. Ctrl+Space doesn't help either of course.

Thursday, August 02, 2007

Migration: VS2005 Stock Web Site Project --> VS2005 SP1 Web Application Project

I'm following these instructions by Scott Guthrie on updating my Web Site project to a Web Application Project.  It sounded good after reading Rick Strahl's advice here.  Below is my journal of following those steps, in case this process need be repeated, or someone else finds it helpful.

Step 0 : I already have WAP installed, having VS2005 SP1.

Step 1 : I opted to create a new Project in my current Solution.

Step 2 : Everything seems to go swell here.  We'll see if I missed any references or dependencies later on.  This is kind of interesting compared to the stock project options.  Instead of having the "Bin" directory and putting dlls in there, I add references and the dependencies will be compiled into my project assembly I imagine.

Step 3 : I did the copy paste in Visual Studio like Scott recommends.  Everything seemed to go well.  I did get some "Overwrite files?" requests when copying the \Bin directory.  That's because VS physically copies the assemblies for the references I added in step 2 to the \bin folder in the WAP whenever I build and they are out of date (or not there).  So, no big deal.  TAKE 2: Oops.  I realized that if I copy all of the files this way (right in VS), I'll loose all of the source control history I have in Subversion.  Instead, I copied them all over using the subversion copy -- which is to say I did a Branch/Tag (cheap copy) of the old project to a new directory, then copied the WAP files to that directory and renamed the directory to the WAP name.  Confused?  Ok, I had \web as the old stock project, and \stations as the new WAP project from step 2.  I renamed \stations to \stations2, did a branch/tag of \web to \stations, and then copied the files out of \stations2 into \stations and deleted \stations2.  Then I hit refresh in Solution Explorer and nothing!  Well, naturally there is nothing.  This is back to the good old project model now, where all files in the project must be added.  So, I clicked "Show All Files" at the top of the Solution Explorer and added those files that I wanted by right-clicking on them and doing "Include in project".  I did everything except "obj" and "bin" folders.

Step 4: Everything seems to have gone fine here, but it won't compile now.  I expected that.  First things I did: I did some SVN rename magic to make the App_Code folder (which the convert renames to Old_App_Code) into the "Source" folder, and maintain the file source control version info.  Then I pointed the "Protos" database in SQL Server to the new copy of the protos.mdf file in SQL Server Management Studio (delete, attach). The Full Text Catalogs can't come along for this ride, so I re-run the script I have saved that makes it, along with all the indexes.  Now when I try to build, I get missing references to all my SubSonic generated classes.  That's because before I was using the SubSonic build provider (the .abp file in App_Code) but that won't work in a Web Application Project, because the compilation doesn't happen on the fly.  WAPs don't support Build Providers.  Remove the Build Provider section from the Web.config, it'll do me no good. So, I need to physically generate the class files - I know the title is "without a website", but this webcast by Rob, daddy of Subsonic, explains how to use SubSonic commander (subsonic.exe) to generate your files, and how to make a cool little button to do it.  I think their might be some other tools or Macros you can use here, but I'll look into that later.  For now, this works.

The next problem: one of my files did not get ".aspx.designer.cs" files generated for them, and thus cannot compile.  I had already read about this and other problems on Rick Stahl's blog.  I tried right-clicking on the .aspx file and selecting "Convert to Web Application." This showed me what the problem was.  "Cannot convert: unrecognized server control uc:DynamicDropDown!"  At first I thought that updating my Web.config file to point to the new "Source" code directory for its "assembly" attribute would fix it, but that did nothing.  So, I commented out the custom controls and then did the convert.  It worked!  Then I uncommented them back in and wha-la, a successful build of the project!

Step 5 : Well, the custom control was still giving me trouble.  So, I finally just stopped searching for strange solutions and did what you are supposed to do in the first place: I created and put the custom control in it's own C# class library project.  Added a reference to this project in my WAP, and updated my control registration in my web.config to match.  Works like a charm, although it is kind of annoying to have to build a second project just for this custom control:


/// <summary>
/// This DynamicDropDown behaves identical to the
/// DropDownList control, except that it does
/// not have the [SupportsEventValidation] Attribute,
/// and thus does not participate in
/// event validation. This makes it ideal for use with
/// the CascadingDropDown AjaxControlToolkit
/// Extender control.
/// </summary>
public class DynamicDropDown : DropDownList

Step 6 : Hmmm... adding the new namespace to all my forms, and then updating all of the "inherits" fields.  I think I'll save this for tonight.  I'm tired, and I spent ALL day working on this.  I should post something fun to my "blog" every now and then, like my cousin James does.

Monday, July 16, 2007

ASP.NET Control Styles

I feel like a complete idiot.  You CAN give ASP.NET controls element level style information.  E.G.:

<asp:Label ID="lbl" runat="server" Text="Hi" Style="border: solid 10px Blue;" />

I assumed this wasn't possible, and that you had to use asp.net skins or something, simply because "Style" doesn't come up on the intellisense for an ASP.NET control, and it does for a regular html control like <input type="button" /> ... etc. VS 2005 will even give you help with writing the style once you are in the double quotes after the Style attribute.  Sometimes I feel like instead of spending time with my family, or enjoying a good game, I should spend every moment of my life I'm not at work reading about stuff I use at work.  :-(  I guess I'll just keep looking at example source code and such to keep learning all these little nuances, tips, tricks, and design patterns.  I figured this one out while figuring .skin files out while looking over the StarterSite that comes with SubSonic.

Thursday, July 05, 2007

Wrapping a Flash SWF <object> with Hyperlink Anchor <a>

The quick answer to this problem (at least if you want browser compatibility): it is impossible - you must have any hyperlink you want your flash to link to to actually be in the flash file itself - that is, you have to make a button and have it be a link in the .FLA or .SWF file itself.  So, if this link has to be set at run-time, you'll need to make a special "Loader" flash file and have it have the transparent button in it.  That part of it is above me (for now).  Maybe I'll write about making one of those when I figure that out.

So, you should know that this does not work after doing a little Googling:

<a href="medium.aspx?id=25">
<object width="200" height="128" quality="Medium" loop="true" play="true"
data="media/static/1_25.swf" id="Flasher1" type="application/x-shockwave-flash"/>

What also doesn't work is trying to make a <div>, setting it to position:fixed, and z-index: 10000.  Even if you make the <div>'s background-color transparent, you will no longer be able to see the Flash file (at least in Firefox you won't be able to).

Thursday, June 28, 2007

Windows Live Writer Test

I'm writing this post using my freshly downloaded and installed copy of Windows Live Write (Beta).  I've talked about using ScribeFire in the blog before - I was impressed initially but have since been disappointed by the quality of the posts it makes to Blogger.

So, we'll see how Live Writer handles formatting and such.  Couple of neat things I've noticed so far, that were missing in ScribeFire:

  • You can goto the View menu and choose to see the HTML Code for your post, A "Web Layout" mode that gives you your post in a WYSIWYG format using the style sheet you have applied to your blog, and even a "Web Preview" mode that shows you what your post should look like if inserted into your blog as is.
  • The "tags" (categories WLW calls them) support seems to be good, and seems to incorporate the tags I have already used on my Blogger blog.
  • You can insert all sorts of neat stuff (Pictures, Links, Tables, Maps) and even extend what you can insert by downloading Insert plugins from Windows Live Gallery.  I saw the "Insert from Visual Studio" plugin and had to have it right away.  Lets try it out.

Here is some code inserted using "Insert from Visual Studio" plugin:

    /// <summary>
/// Grabs an integer parameter from the HttpContext.Current.Request
/// </summary>
/// <param name="sParam">The name of the parameter</param>
/// <returns>The int parameter, or -1 if there was no such parameter.</returns>
public static int GetIntParameter(string sParam)
int iOut = -1;
if (HttpContext.Current.Request.QueryString[sParam] != null)
string sOut = HttpContext.Current.Request[sParam].ToString();
if (!String.IsNullOrEmpty(sOut))
int.TryParse(sOut, out iOut);
return iOut;

Awesome!  It pasted in just fine, but my layout was too narrow, so the code was wrapping in places it shouldn't.  So, I switched over the HTML source view on WLW and wrapped the whole thing in a <div> and gave it some width. (WLW handled me typing that <div> just now too - another thing to note).  Anyhow, once I gave the div a style="width: 100%", I could switch back to the Web Layout view and click on the div, and drag it's size around using drag handles.  Was not expecting that, but it's pretty neat!

Alright, time to post this thing and see if WLW can make the actual post look as nice as the WYSIWYG view it is giving me.  Then, I'll test the update post capabilities of WLW (if there are any) to let you know.

Update: Ok, doing the update was pretty easy.  Using the "Open" dialog, you can see posts that were recently edited in WLW, or you can even click the Blog view button to edit posts that are already posted using other means.

Everything looked great on the actual blog too!  The only small issue was that my inserted Code block had a noticeably bigger space below it in Firefox than in WLW WYSIWYG view.  I'm going to try changing the height on the <div> I wrapped that in. 

PS: Looks like you can do Technorati tags with this too:

Technorati Tags: , ,

Wednesday, June 27, 2007

Ending an ASP.NET Response during processing.

Your ASP.NET 2.0 page is in the middle of processing a Request (thus creating a Response), when all of the sudden you need to stop the request. Why? Well, say you just called:


And now you need the current Response to stop processing (no more event handlers to fire, etc). How do you do that? That's the question I had for some time, but didn't have time to investigate it further. After familiarizing myself more with the objects in HttpContext.Current, It became more obvious with where I needed to look, and there it was:


The description says that this method "Sends all currently buffered output to the client, stops execution of the page, and raises the EndRequest event." Nice.

Thursday, May 03, 2007

Full screen Flash 9 standalone in Linux

It would be really useful to be able to open a standard Flash 9 .swf in the standalone player that you can get for linux at http://www.adobe.com/support/flashplayer/downloads.html.

I envision something like this:

./flashplayer --full-screen ~/some_flash.swf

If I could do that, then I would be able to incorporate flash into the "off-line, demo" kiosk units I make using DSL on compact flash - that would make the boss happy. Unfortunately, everything on the net seems to indicate one needs to put some actionscript in the first frame of the flash in the "authoring" stage of things. That would defeat the purpose of my project though, since I can't guarantee our resellers or other folk will all be able to do this.

Maybe I'll have to spend some of my quality free time reading up on SWHX.

Technorati Tags: ,

Thursday, April 19, 2007

ASP.NET 2.0 app under IIS 5.1 on my Development Machine

I made my initial attempt to host an ASP.NET 2.0 application under IIS 5.1 on my development machine. The Application was the SubSonic 2.0 Beta 3 SubSonicCentral demonstration site. Normally I use the ASP.NET Development Server for this sort of thing, but I got tired of loading up the SubSonic solution in VS 2005 just to view this site - VS 2005 is a resource hog like no other. Anyhow, I ran into issues, and found solutions. Posting them here so I can reference them later if need be.

Issue the First: App-Domain could not be created. Error: 0x80131902

This error shows up in the Application Event Log under Administrative Tools -- Event Log. The actual message given to you in your browser tells you the "Site is Unavailable" and tells the administrator to look at the Event log. Solved this by following these instructions (Jonathon's Blog) - note: I got some error messages during the "aspnet_regiss.exe" steps, but they didn't seem to affect the outcome.

Issue the Second: Could not access database "Northwind" with user login ADAM-IMS\ASPNET

In VS 2005 ASP.NET Development Server, the .NET process tries to access the SQL Server Express instance using my login account (ADAM-IMS\Owner). IIS uses the ASPNET account. One simply needs to add a Login in the SQL Server Management Studio, and then give the user permissions on the Database.

Technorati Tags: , ,

Thursday, April 12, 2007

RAS (Dial-Up) Tip/Trick for Auto dial

So, you want a dial-up connection to dial whenever a program "asks" for a remote resource (i.e. uses the internet)? Pretty standard - you goto the Internet Settings in the Control Panel, and look at the Connections tab. You should see any dial-up connection you have in the listbox, and below that the options you seek -- either "Always dial this connection" or "Dial this connection whenever a Network Connection is unavailable." I usually stick with the second option, since it seems more stable and reliable on the embedded systems I maintain.

This is all well and good, but I soon ran into a problem. After going through this setup, the first time you open an internet-savvy application and it attempts to use the remote resource, you'll be presented with a small dialog that lists the connection, has three buttons (Connect, Settings, and Work Offline) and also has a checkbox that is empty marked "Connect automatically." The problem is, the devices I'm engineering don't have a keyboard or mouse hooked up to them, and one of them is about 3 hours drive from here. So, the first time it drops the internet connection (which is dialed at startup fortunately) and these settings cause it to automatically connect again, it will throw this little dialog up on the screen and sit there - unaccessible to me since it is offline.

I used process monitor and my own development computer to (miraculously) narrow this down to one registry key. Interesting factoid: on my development laptop, Windows XP Pro hits the Registry (Mostly Reads fortunately) around 50 thousand times in the few second interval I captured using procman.exe! Here is the key:

[HKEY_CURRENT_USER\RemoteAccess\Profile\sprint] "AutoConnect"=dword:00000001

Oh, and make sure you change "sprint" to the name of your dial-up connection! [Thanks to KM from the XPE newsgroup for that reminder!] If the key exists, and is set to '1', it is equivalent to having checked "Automatically connect" in that annoying, useless dialog the first time.

Technorati Tags: , ,

Couple of neat Firefox Extensions

I downloaded a neat looking Firefox extension called "ScribeFire."

It's a tool that lets you post to your blog in the bottom half of Firefox while looking at pages in the top half. I don't always need to look at something on the web to be blogging - I seldom do actually - but it is still neat to use, and lets me skip the whole "log into Blogger, click new post" step.

Another really slick looking extension I just picked up is FireFTP. Its function is pretty self-explanatory. I like the interface (which is a hard thing to find in a free FTP client) and it has the few advanced features I usually look for in an FTP client (folder diff, session manager, etc.)

Powered by ScribeFire.

Update: I've since stopped using ScribeFire. It makes my blog posts ugly with "&nbsp" everywhere and such.

Technorati Tags: ,

Tuesday, April 10, 2007

I was having issues with images flickering in our Delphi client program - it is going into the bit bucket anyhow, but the flicker was really noticeable on the new XP Embedded image I'm trying to make.

The solution, from my newsgroup post:


I don't know why I didn't think of this earlier. I just turned on Double Buffering in the application itself for the form that displays the images, and it looks sexier than ever! Even on the full-blown images and my development computer.

Off topic, but if anyone is wondering this site has great info on removing flicker from images:


Good Luck!


Wednesday, April 04, 2007

Linux disk imaging made easy

You have a small "drive" (I'm actually using a 1GB Compact Flash card) with 3 partitions on it - you want to preserve the information on each of these partitions, and the boot information at the front of the "drive."

# to make the image:
dd if=/dev/hda | gzip > hda.img.gz

# to restore the image, or clone to another disk:
gunzip -c hda.img.gz | dd of=/dev/hda

Be sure to change 'hda' to the appropriate drive.

Friday, March 30, 2007

Move Windows system disk to New PC Home

Here is a trick I picked up in my amateur computer repairing (Every geek needs one of those "No, I will not fix you computer!" shirts, no?).

You have PC A running windows XP/Pro/(Vista?) and you want to keep all your Windows settings, program installs, etc. and use them on your new, shiny PC B. Maybe you have even assembled PC B yourself and didn't order a new hard drive in anticipation of using your old system disk. Well, chances are that if you just rip your hard drive out of PC A and stick it in PC B, Windows won't boot. You'll get a blue screen of death STOP ERROR or maybe it'll get to the splash screen but then freeze up. Certain drivers for your motherboard and chipset are sort of "embedded" in your windows install so deeply that it can't adjust for the new hardware of PC B.

The Solution? Grab your Windows install disk and boot from that. When prompted, select "Install windows" or whatever, and accept the EULA. Eventually, the installer should say that it is scanning your system for previously installed versions of Windows. It should detect your working windows XP installation and ask you if you would like to repair this installation. Hit 'R' or whatever it says will repair the installation. Thirty minutes or so later, you should be up and running your old installation on your new PC. Certain things might need some fixing afterward (for instance, depending on your instal CD version, you might need to install service packs and hot fixes again) but it may save a lot of time compared to starting from scatch.

I know Microsoft has some kind of "Transfer Files and Settings" application that is supposed to do something like this, but I doubt it works so smoothly, and it requires multiple hard drives (one for the new install, one to keep the old install).

Thursday, March 15, 2007

Authoring your own XP Embedded Components with Files

From the very beginning of working with XP Embedded, one of my goals was to be able to make our custom client application the "shell" for our run-time image, like this. Also, I thought it would be cool to import the .inf files from the mainboard drivers we needed to install -- the Network Adapter and the Video Adapter drivers. I had seen Mike Hall or someone at Microsoft do this by launching the File -> Import... command from Component Designer. Well, I ran through all the steps for these processes, and imported the components into the Database ( Tools -> Component Database Manager -> Click "Import .SLD" ), but when I added my new custom components I got error messages about not being able to find all of the Files associated with the component - one error message for each file.

After some experimentation, and perusing a few forums, I determined that I needed to make my own Repository for the Components I was making, and then set the Repository in the Component Details page (it is "Unknown Repository" by default). You can find detailed information on how to do this here.

I did something slight different though in order to have a single repository for all of my custom components, and have that repository listed in the Component Database Manager, as well as in the "C:\Windows Embedded Data\Repositories" directory.
  1. Create a new .sld in Component designer
  2. Right click the Repository tree node and click Add Repository
  3. Name your repository something appropriate (e.g. "MyRepo" or "ZipCo Custom Components") and set the source to a (pre-created) directory of your choice. The directory should have a text file or something in it marking it as your repository, since it will be given a long, hard to remember GUID for a directory name after step 4.
  4. Save the .sld and import it into your Component Database. Note: In the import .sld dialog make sure you have the "Copy Repository to root" checkbox checked.
Now you have your own repository in the database, and in the repositories root directory (probably "C:\Windows Embedded Data\Repositories"). Whenever you make a Custom Component of your own that has one or more files, set the Repository in the Component Details page to your custom repository (it should be listed along with the main XPe repos) and copy all of the files you use into the repositories physical folder.

PS - If you see error messages importing your .inf driver file, read this before you assume something went terribly wrong. :-)

Monday, March 12, 2007

ASP.NET Forms Authentication strange behaviors

After I got ASP.NET Forms Authentication up and running on the web application I'm developing, I started having a few problems -- it took me awhile to figure out that they were caused by having Forms Authentication enabled.

The first issue I had was that the site would redirect to login.aspx like it was supposed to, but the login.aspx page would be missing all of the style information from our CSS style sheet. I looked in the Firefox error console (Firefox Web Developer Extension ) and noticed an entry about the site being unable to grab the style sheet because it was the wrong MIME type: it was text/html, when it expected CSS files to be text/css. After banging my head against the MIME type error message for awhile, I had the idea that maybe the type was text/html because it was getting a 404 response when asking for the style sheet. Sure enough, it wasn't too long then before I figured out that Forms Authentication and my Web.config settings were preventing unauthorized users from grabbing my style sheet. Solution - made a second Web.config and placed it in my App_Themes directory where my style sheet lives.

<allow users="*">

The solution to my next problem was now pretty obvious. Any javascript file I embedded in my login.aspx page would return a syntax error on line 2 or line 3. It even did this if the .js file was completely empty! I quickly realized it was the same problem, just a very different symptom. Soulution - place another Web.config in your "scripts" directory, or make a "public_scripts" directory if you need to protect some scripts from unauthorized users and place your Web.config there.

Friday, March 02, 2007

XP Embedded Tricks

I recently posted on the microsoft.public.windowsxp.embedded newsgroup a couple of questions I had about XP Embedded related to work. The short version of the questions:

1. Is there a way to determine which service inside a svchost.exe process is causing the problem when presented with a "svchost.exe - Applicaton Error" ?

2. Is there a way in XPe to suppress displaying error messages?

The short answers (thanks to KM in the same newsgroup!):

1. Sysinternals (now Wininternals) Process Explorer can give you just such info. It's like Task Manager on steroids! (I had used it before, but didn't put two and two together :-)

2. Yes! A simple registry change can suppress many error from being presented to the user on XP embedded.

Tuesday, February 27, 2007

Using January CTP of ASP.NET 2.0 Ajax Extensions

So, a bunch of the things I'm reading in my current book (see post below) don't work, because Microsoft whacked off a bunch of the features of their ASP.NET 2.0 Ajax Extensions in order to get to the current release versions (1.0). In order to get these features back, you need to install the January CTP release in addition to the standard RTM (1.0) release. After you goto ajax.asp.net and download the CTP and run the installer, not much has changed.

To get the CTP (aka "Futures") stuff into your scripts, you need to manually add references to the scripts in your ScriptManager, like this:

<asp:scriptmanager runat="”server”" id="”ScriptManager1”">
<asp:scriptreference assembly="Microsoft.Web.Preview" name="PreviewScript.js" />
<asp:scriptreference assembly="Microsoft.Web.Preview" name="PreviewGlitz.js" />
<asp:scriptreference assembly="Microsoft.Web.Preview" name="PreviewDragDrop.js" />

Now you should be able to use stuff like Sys.Preview.UI.Button again (note the need now to puts "Preview" after the first part of the namespaces).

Monday, February 26, 2007

Adding Color to "ls" in Bash

Ever since I installed Debian on our "ol' junker" Poweredge server at work, I've noticed that executing ls doesn't give me the same, colorful output as I used to get with the linux machines at work (and with every other linux install I've seen). I did some investigation, and found the following in in ~/.bashrc:

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If running interactively, then:
if [ "$PS1" ]; then

# don't put duplicate lines in the history. See bash(1) for more options
# export HISTCONTROL=ignoredups

# enable color support of ls and also add handy aliases
eval `dircolors -b`
alias ls='ls --color=auto'
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'

The alias ls='ls --color=auto' should give me the colorful output I desire. What gives? Well, the comment at the top says that this file is executed when a non-login shell is opened. However, I want to see the colorful output even in my Putty terminal, not just in Xterm in Fluxbox or whatever. So, I cracked open ~/.bash_profile:

# ~/.bash_profile: executed by bash(1) for login shells.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
umask 022

# the rest of this file is commented out.
# include .bashrc if it exists

#if [ -f ~/.bashrc ]; then
# source ~/.bashrc

Aha! This is the script that is executed for a login shell. After uncommenting the last three lines and re-starting the shell, my ls's are looking very nice.

Update: To achieve this same thing for your root shell, you need only look to /root/.bashrc -- mine already had the color info commented out in that file, so I simply uncommented it.

Foundations of Atlas Problems

I'm reading through the Apress book Foundations of Atlas: Rapid Application Development with ASP.NET 2.0 and when I hit chapter three, I started to notice a lot of the source code is broken. I kinda expected this sooner or later, since the author wrote the book against a CTP edition of what was then codenamed "Atlas." I'm using ASP.NET 2.0 AJAX Extensions version 1.0 which is the release version of the same Microsoft Ajax technology.

I found this to be very helpful:

It seems to be a section-by-section duplicate of the same information presented by the FOA author, except with examples that work with the latest version of this technology!

Internet Explorer vs Firefox XMLHttpRequest.send()

Quick note to self - This will work in Internet Explorer no problem:


However, it will generate javascript exceptions in other applications (such as Firefox 2.0). To get around that, instead do this:


Disqus for A Nofsinger's Blog