in

ASP.NET Weblogs

Phil Scott's WebLog

Quite exciting this computer magic
  • Booting Windows 7 and VS 2010 on SSD in 18 seconds

    I've been doing quite a bit of work with VS2010 recently as we've prepared for our launch of our free ASP.NET 4 hosting, and I had a fresh install of Windows 7 without the typical cruft that comes with our environment. So I wanted to show how quick booting off of a SSD is. There are two pieces of hardware EVERY developer must have - multiple monitors and a SSD. I've said it over and over again, I have never seen a single upgrade improve the performance of a PC more than my X-25M drive since I first saw what the Voodoo2 could do.

    I took this video to show how quick the sucker is because until you have used it, you probably think I'm full of crap. But this sucker FLIES. My previous OS partition was running on a couple of 10,000 RPM drives running RAID 0, and there is simply no comparison. I skipped the BIOS and went right to the boot loader. It boots Windows 7, and then I dumped VS2010 Ultimate and Firefox 3.6 in my start up folder. I'm ready to rock and roll in 18 seconds.

    Oh, and one more thing - this is a VHD hard drive that I'm booting off of so it's actually slightly slower than my typical install. I just didn't want to mess around with that on video due to all the logins and junk I gotta do by hand when logging onto our network.

    I know a bunch of people are waiting for the prices to go down, but don't! You may get it $100 cheaper a year from now, but this thing is well worth the extra $2 a week to have it right now.

  • 404 Errors with FileUpload with IIS7

    I was getting some 404 errors while using the FileUpload control. I tested it out on my local machine and  using

    <system.web>
            <httpRuntime maxRequestLength="256000"/> <!-- request length is in kilobytes -->
    </system.web>

    worked fine. But once I moved it onto IIS7 everything started freaking out. Turns out IIS7 look for a different setting:

        <system.webServer>
            <security>
                <requestFiltering><requestLimits maxAllowedContentLength="262144000" /></requestFiltering> <!-- maxAllowedContentLength is in bytes. Defaults to 30,000,000 -->
            </security>
        </system.webServer>

    My searches really only directed me to modifying the system.web, so hopefully this will help someone out.

  • Watch Out for Request.Browser.MajorVersion in ASP.NET 2.0

    I awoke to 1500 exceptions published to me this morning from our public site running ASP.NET 2.0.  Not good times.  "Luckily" they were all the same: Value cannot be null.  It seems one of the components that we are using is calling Request.Browser.MajorVersion and blowing up on goofy user-agents.  In this case the user-agent of doom is "YahooSeeker/1.2 (compatible; Mozilla 4.0; MSIE 5.5; yahooseeker at yahoo-inc dot com ; http://help.yahoo.com/help/us/shop/merchant/)".  For whatever reason ASP.NET 2.0 cannot parse the MajorVersion out of that and tries to call int.Parse on a null value, causing an error.

    Luckily we own the source code to this particular component, so I just wrapped the calls to MajorVersion in a try block so that the entire site doesn't blow up on bogus error codes, so hopefully if you run into that particular error you'll be able to track it down.  I haven't tried any of the other properties of the Browser class, but if you are relying on them for anything you might want to first test them out with a rediculous user agent and see what blows up. 

  • Installing Ubuntu on Virtual PC 2004

    I decided to give Ubuntu a try in Virtual PC to see how this distro works.  So far, I'm pretty damn impressed.  But getting it up and running in a Virtual PC wasn't quite as obvious as I hoped it would be.  Here are the steps if anyone else wants to try out this distro.  I basically just went through a default install, and when the thing booted up it freaked out on the display.  This is actually quite common with Linux distros that I've tried in Virtual PC.  Keep in mind, I'm not even too terribly sure how to pronounce Linux, so I just kinda faked my way through the steps.  You might know a really cool way to do some of these steps, and that would be great if you let me know

    So after booting up in messed up graphics land, I was able to click the giant ass Reboot button on my 160x120 screen.  When it was rebooting, I hit ESC during Grub and booted into the recovery console.  This gave me root access (is this secure?  Sure as hell didn't seem like it to me...).  Once I was in there, I found the configuration file for the graphics card in /etc/X11.  Sso type in cd /etc/X11, although I certainly hope even the most harden of MScentric people can figure that out :).  Once in there I opened up xorg.conf using pico (so type in pico xorg.conf - isn't this fun?).  Browse down to the screen section.  Opps, looks like the defaultDepth property is 24, which VirtualPC doesn't support.  I changed this to 16 and hit CTRL-X to exit (saving when prompted of course).  Typed in reboot and awaaaaaaay we go.

    Once I was logged in, I wasn't able to hit the internet but this was an easy enough fix.  Just go to System | Networking and enable the Ethernet connection.  At this point I was good to go.  I don't think I have sound yet, but I really could care less.  But if a wise soul would like to enlighten me, I wouldn't mind either.

    So there we go.  I'm impressed with how easy this was to get up and running (besides virtual pc graphics snafu), and it looks great too.  I'm tempted to throw this on my laptop that I keep in my living room just because so many people use it.  You'd be surprised what my friend's girlfriends manage to install while we are watching football.  Stupid yahoo games.  But I digress.  So why all this trouble to post this on an ASP.NET site?  I've been tagged with doing a lot of the design work for my companies new site, and well, the old version didn't exactly work in Linux, i.e. the menus and some content doesn't show up at all.  Remember folks, Verdana isn't installed on everyone's PC.  It looks like the default sans-serif font is pushing some of the content around, which was dumb of me not to anticipate, so I'll have to fix this.  Good times.  Good times.

  • Accessing the Html Header in ASP.NET 2.0

    I feel a bit silly for not figuring this out quicker, so hopefully I can redem myself by posting this to help people out.  Taking a look at the Page class there is a Header property that looks tempting to be able to do something like dynamically add a stylesheet.  The problem is that when you type in Page.Header it doesn't appear that you have full control over the header, even though there is the ever so tempting System.Web.UI.HtmlControls.HtmlHead class.  What I had been doing is throwing an id and a runat="server" onto the head tag in my HTML, which I really didn't like because an id tag on the head tag isn't valid XHTML 1.1. 

    Today, a break through.  This has always bothered me, so I took a deeper look and it turns out that Page.Header is defined as IPageHeader.  Perhaps, just maybe I could cast Page.Header into System.Web.UI.HtmlControls.HtmlHead.  And sure enough, it worked great.  Anyways, I feel a little silly about not figuring that out sooner but now that I've gotten this working I feel much better.  Anyways, here's some example code to add a stylesheet to a page:

            Dim header As Web.UI.HtmlControls.HtmlHead
            header = TryCast(Me.Page.Header, Web.UI.HtmlControls.HtmlHead)
            If header IsNot Nothing Then
                Dim link As New HtmlLink
                link.Attributes.Add("href", "~/whatever.css")
                link.Attributes.Add("media", "screen")
                link.Attributes.Add("rel", "stylesheet")
                link.Attributes.Add("type", "text/css")
                header.Controls.Add(link)
            End If

  • The Curious Incident of the App_Offline.htm in your ASP.NET 2.0 App

    I've gotten more than three issues sent to me recently regarding why an ASP.NET 2.0 app suddenly starts throwing up 404 errors, and each time there is a single culprit: app_offline.htm.  I'd point towards some documentation, but honestly I just can't find any out there, so hopefully this will help people figure out what is going on.  When ASP.NET 2.0 sees this file, it basically shuts down the process.  This is useful if you need to over write a MDB file for example.  

    Strangely, each time I've encountered "issues" with 404 errors being thrown by applications when the file exists, this file exists and the customer doesn't know how it got there.  I'm not sure if they were just going through some demos and missed a step or something, or perhaps something in VS2005 or Web Dev Express is creating the file automatically.  Perhaps one of the publishing tools sends the file up, and fails to clean it up.  So there you go.  Hopefully this helps someone out there figure out why they are suddenly getting 404 errors on pages that exists, or maybe it helps people manage deployments easier by using app_offline.htm for what it was designed for.

  • Deploying the ASP.NET 2.0 Personal Site Starterkit

    I've seen quite a few questions regarding how to deploy the Personal Site Starter Kit to a hosting account, so I thought I'd write up some guidelines on how to do this.  These directions have really only been tested with the MaximumASP's free beta account, but they should work with any of the other providers assuming they give you some type of SQL Server as the backend.

    The main problem with deploying the Personal Site Starter Kit is that by default it assumes that 1) you have SQL Express running on the webserver and 2) you are using the configuration settings provided in machine.config for the membership / role providers.  Unfortunately, SQL Express is simply not meant to be ran on shared webservers, so obviously we are not going to be able to use this as our backend.  Luckily, Microsoft has recently released some generic scripts for creating the database for the Personal Site Starter Kit, so we can use those to create the tables needed on our SQL 2000 database.

    Step one is going to be creating the support tables for the membership / role providers.  The .NET Framework SDK includes a tool called aspnet_regsql that will create the tables / sprocs needed.  On my machine it is located at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\aspnet_regsql.exe.  Run this program and it pops up a wizard to create the tables.  Choose "Configure SQL Server for Application Services", and click next.  We are now presented with a dialog asking for your login information.  Enter your SQL Server credientials and choose your database.  Note: you may get an error on the drop down.  That's fine, just type the database name in instead.  Finish running the wizard and you should have a bunch of shiny new aspnet_ tables in your database.

    Step two is getting the Personal Web Site Starter kit or the Club Site Starter Kit generic sql scripts.  The ASP.NET Starter Kit page has links for both of these files.  Download these files, and extract the .SQL file.  Now it's just a matter of opening up Query Analyzer or SQL Express Manager, connecting into your database and executing the script.

    Now that we have the database ready, it's just a matter of updating web.config to point towards the proper database.  There should be two connection strings, Personal and LocalSqlServer.  Update both of these to point towards your database. You can now connect into your site via the ASP.NET Configuration page to create yourself an admin user, or if you just want to see if it worked, fire up the website.  Feel free to delete the MDF files in your app_data folder.  We don't need them anymore.

    Now, for a little rant.  Yes, we are now using a connection string called LocalSqlServer to connect into a remote sql server.  And some might wonder why we had to remove a connection string that doesn't look like it had been defined yet.  And who knows how the providers are configured.  Here's the secret:  To make things "easier," Microsoft has created a default Connection String and Providers in machine.config.  I would highly recommend not using these at all costs in your application.  They are there simply for people who want to go "hey, i just created a website in three steps!"  Relying on those default providers will simply make development, maintence and deployment a pain in the butt (who knows if your host will even have those entries in their machine.config, or that they have the same values that you are using on your server).  If left up to me, Microsoft would not include these entries in machine.config and assume people will configure their membership / role providers on an application basis, not on a machine wide basis.  Makes sense to me.

    So, my long running, rambling point:  Take some time to look at the documentation for the providers.  Heck, look at your machine.config.  Copy and paste the membership configuration stuff into your web.config.  And never, ever, ever for any reason rely on localSqlServer or the default providers from your machine.config in your applications.  That will only cause you headaches down the road when it comes time to deploy, plus prevent you from learning how these things are configured.

  • Premature Jubilation

    Oliver Sturm sent along a couple of links to his blog where he's taken a much deeper look than my "oooooooh, pretty!" reception to the new image library that is shipping with VS2005.  And after taking a deeper look at these images, I've come to the same conclusion:  ugh.

    Like Oliver said, if you want an app that looks good (or aren't creating VS2005), then you might want to venture over to glyFX or my favorite Glyfz.  It looks like Glyfz is even offering their alpha-blended PNG images for free when you buy the Office 2003 style image set.  That's a deal in a half.  Now all I need is an excuse to throw away our UI to get my boss to buy the set...
  • New Graphics with VS 2005

    Holy crap, just found these things in my Visual Studio 8\Common7\VS2005ImageLibrary folder.  In there you will find a zip file with about 800 images to use in your apps.  Unfortunately these all look to be 16x15 in bitmap format and not png or gif for the web, but hey, it's a start.  This is something I've been complaining about for years.  Should be great for winform toolbars, but not so useful for the web.

    No new icons though.  It looks like giving applications the rocket ship icon will still trendy.

    Post Script:  As I finished typing this up, this movie popped up in my RSS reader as an introduction to the VS 2005 Image Library.  Sweet!
  • Validating XHTML with ASP.NET 2.0

    With the go-live of ASP.NET 2.0, I've been actually using it at a level of more than "ooh, pretty new feature." I'm kinda of a standards nerd, so naturally I've been messing around with the XHTML output and making sure I like what I'm seeing.  So far, so good. But I ran my page against the W3C's validator and it freaked out, complaining about form tags having names and the such. So I take a look at the source, and it looks good to me. So I go back to the validator, and run it one more time, this time enabling "Show Source." Ah, there's the problem. ASP.NET thinks that the validator is some ghetto browser from 1996 so it is sending it invalid markup.

    The fix was pretty easy once I tracked it down. Simply update the browseCaps section of your web.config to tell ASP.NET about the W3C's user-agent. Here's the code I'm using:

    <case match="W3C_Validator+">
       browser=Netscape
       frames=true
       tables=true
       cookies=true
       javascript=true
       javaapplets=true
       ecmascriptversion=1.5
       w3cdomversion=1.0
       css1=true
       css2=true
       xml=true
       tagwriter=System.Web.UI.HtmlTextWriter
    </case>

    Now when you validate your page, ASP.NET will send out the same HTML as it would if Firefox or IE were requesting the page. Now what I'd really like to do is tell ASP.NET to shove it, and spit out XHTML on unknown browsers. Anyone have any ideas?

More Posts Next page »