Scott Hanselman

Microsummaries - Über Simple Syndication

September 5, '06 Comments [0] Posted in ASP.NET | DasBlog | Musings
Sponsored By

I'm still not quite sure why Microsummaries are useful...seems like USS (Über Simple Syndication - my term) to me. I've been meaning to add this to my blog since I heard about it a few months ago, but then MikeG added microsummaries to his site and I figured if a Luddite like Mike would support this emerging format, then I would too. :)

Basically this is how it works:

  • Add a <link> tag inside the <head> of your document like this.
  • In your Microsummary endpoint, return some text/plain with the text you want to show up in the live bookmark.
  • In FireFox Beta 2, either bookmark this site, or drag a link to this site to your toolbar:
    Hanselmanmicrosummaries
  • If you've created the link in your toolbar, right click and select Properties and pick the Microsummary (or "Live Title"). If you've created the link via Add Bookmark, you should already be at this dialog.
  • Once the Microsummary has been selected, it will show up as the title of your bookmark or toolbar button.

This is easy to do to any ASP.NET site. Add an very basic HttpHandler with code like this:

using System;

using System.Web;

 

namespace Foo.Web.Services

{

    public class MicrosummaryHandler : IHttpHandler

    {

        public MicrosummaryHandler() {}

 

        public bool IsReusable{get{return true;}}

 

        public void ProcessRequest( HttpContext context )

        {

             context.Response.Write("Yay Microsummaries...get your summaries here. Get them anywhere.");

        }

    }

}

And add it to your web.config, of course:

<httpHandlers>
            <add verb="*" path="microsummary.ashx"
                      type="Foo.Web.Services.MicrosummaryHandler, 
                            Foo.Web.Services" />
</httpHandlers>

You can also use Microsummary Generators that are basically formalized screenscraping of existing (x)HTML. You make an XSLT that yanks what you want and turns that into plain text suitable for a toolbar button.

Direct (free) support for this has been checked into DasBlog and will be in the daily builds if we ever get this g*dforsaken thing to ship. :)

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Coding4Fun Hardware Webcast - Available Offline

September 2, '06 Comments [1] Posted in Coding4Fun
Sponsored By

Coding4funwebcast1A few months back I did a Coding4Fun Hardware Webcast. I'll probably do a few more, but for now, I just noticed that it's available offline.

You can download the Webcast as a WMV. You don't have to get the Live Meeting Player unless you want the better quality output.

You have to jump through a few Passport hoops to get to it, but considering that it was a Webcast about Hardware, it's pretty good. I use the Webcam to take photos of what I'm doing, so you get a pretty good idea of what's up. It's more code and demos than slides.

All the demos and code are based on Coding4Fun articles from my column "SomeAssemblyRequired" there. I have two articles in the hopper I've already turned in with two more on the way.

Dan Fernandez has blogged that he's having trouble keeping up, but they are in the middle of a V2 of the whole Coding4Fun site. Be sure to visit his blog and give feedback on what you think can be done to make the site better. There's definitely a Hobbyist Renaissance at Microsoft right now. I'm having a blast, as I hope you'll see in the next four articles where I interface .NET with lots of hardware, some years old, some brand new, some robots and some bar code readers. Very cool stuff.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

A New Private Browser - I mean Browzar - does not work as advertised

September 1, '06 Comments [18] Posted in Reviews
Sponsored By

Browzar_skinsUPDATE: Looks like I was mentioned on the BBC.  I'm afraid they miss the point:

However, some computer experts say they have already identified flaws in Browzar. Scott Hanselman, writing on his blog Computer Zen, claims to have been able to find records of websites he had visited with the program installed.

"Browzar, at least this version, is totally not doing what it says it does," he writes.

The newly released software is entering a market dominated by Internet Explorer.

Of course, the joke here is that Browzar is a wrapper around Internet Explorer.

I had a 2 gig USB Drive, but it was huge and I didn't use it as much as I could. Then I picked up one of these OCZ 2GB Flash for $40 $31 after rebate (that's not a typo!) at Omar's recommendation. It's freaking small.

Then I secured it - you'd be a fool not to, IMHO. Now I'm getting all my Portable Apps moved over to it as well.

Portable apps mean that they can be run directly from a USB Drive without installation. There's a portable version of Firefox, for example.

However, I noticed this little browser, called Browzar, mentioned in this InformationWeek article, that is a single 265k EXE that basically wraps IE 5.5 or above (works fine with 7.0) and is a "private browser." That means it doesn't save cookies or history or autocomplete. Sounds like a convenient thing to have on one's USB drive if one didn't want to leave (blatent) footprints.

Well, since it's hosting IE, I want to see what it's doing. So, I fired it up and visited the naughtiest site I could think of, Pl*yboy, while running Filemon. Here's a screenshot of the cached naughty gifs going in my Temporary Internet Files folder. Notice that Browzar deletes the gifs as soon as it sees them.

Browzar1

Then I closed the browser...You can see here that it deleted a bunch of cookies and such, trying to clean up. However, while it deleted the cookies, it didn't delete the page itself, just closed it.

Browzar3

Notice here, later, I find the file in my IE Cache:

Browzar2

So, Browzar, at least this version, is totally not doing what it says it does. That's a bummer. Maybe next version.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

How to Programmatically Detect if an Assembly is Compiled in Debug or Release mode

August 30, '06 Comments [12] Posted in Programming
Sponsored By

Nagaraj from my company made this little util recently to run against a compiled assembly and see if it is a Debug or Release version. I added the DOS ErrorLevel return codes.

using System;

using System.IO;

using System.Diagnostics;

using System.Reflection;

 

namespace Foo.Tools

{

    class BuildFind

    {

        public static int GetBuildType(string AssemblyName)

        {

            Assembly assm = Assembly.LoadFrom(AssemblyName);

            object[] attributes = assm.GetCustomAttributes(typeof(DebuggableAttribute), false);

 

            if (attributes.Length == 0)

            {

                Console.WriteLine(String.Format("{0} is a RELEASE Build....", AssemblyName));

                return 0;

            }

            foreach (Attribute attr in attributes)

            {

                if (attr is DebuggableAttribute)

                {

                    DebuggableAttribute d = attr as DebuggableAttribute;

                    Console.WriteLine(
                       String.Format("Run time Optimizer is enabled : {0}", !d.IsJITOptimizerDisabled));

                    Console.WriteLine(
                        String.Format("Run time Tracking is enabled : {0}", d.IsJITTrackingEnabled));

                    if (d.IsJITOptimizerDisabled == true)

                    {

                        Console.WriteLine(String.Format("{0} is a DEBUG Build....", AssemblyName));

                        return 1;

                    }

                    else

                    {

                        Console.WriteLine(String.Format("{0} is a RELEASE Build....", AssemblyName));

                        return 0;

                    }

                }

            }

            return 3;

        }

 

        [STAThread]

        static int Main(string[] args)

        {

            if (args.Length == 0)

            {

                Console.WriteLine("Usage GetBuildType <assemblyName>");

                return 2;

            }

            return BuildFind.GetBuildType(args[0]);

        }

    }

}

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

SOLVED: How to Force IIS to load a certain version of the .NET CLR

August 30, '06 Comments [4] Posted in ASP.NET | HttpModule | Web Services
Sponsored By

Micky McQuade turned me on to some code (from MSPSS) to solve my How to FORCE IIS to load a certain version of the CLR/.NET Framework. Greg Menounos also mentioned this solution in the comments.

PROBLEM: As discussed before, you can't use requiredRuntime or any .config changes (any that you ought to) to influence what version of the .NET Framework gets loaded into the IIS worker process. If you are using a .NET object as a COM object within Classic ASP, you'll always get the very latest .NET Framework installed on the machine. The values associated with the (fake) COM Object in the Registry are ignored. NOTE, this problem in with IIS/ASP/ASP.NET. If you're doing other things like calling .NET objects from VB6 Clients or something like that, you can always create a .exe.config and influence things with requiredRuntime like I talked about here.

SOLUTION: The solution is a clever hack. What's the first opportunity to "jump in" and affect IIS? When the ISAPI Filters are loaded. Which ISAPI Filter method is called only once? Why GetFilterVersion(), in fact.

This is one of those 'slap your forehead' solutions because it makes sense when you hear it, but it sounds SO tedious when you come up with it and have to actually sully your nails with C++ again. Sigh, I coded in C++ for 8 years and now not only have I forgotten my ninja skills but I feel slightly dirty when I'm back in there. 

DISCLAIMER: This code of course assumes that there isn't some other higher-priority ISAPI filter doing crazy stuff in .NET. Unlikely, but worth mentioning. It's also totally unsupported, and you didn't get it here. In fact, you don't know where you got it. Who is this? What are you doing here? Move along, nothing to see here! No warranty expressed or implied as I didn't write it. Don't bug Micky or ask MS about it.  There's also no guarantee that this, or anything like this, is a solution for your problem(s).

But it's interesting to read.

BOOL CNativeISAPIFilter::GetFilterVersion(PHTTP_FILTER_VERSION pVer)
{

    LPWSTR pszVer = L"v1.1.4322";

    //or "svr" if you're on a multiproc box and you want the server GC in this process.

    LPWSTR pszFlavor = L"wks";

    ICorRuntimeHost *pHost = NULL;

 

    HRESULT hr = CorBindToRuntimeEx(

        //version

        pszVer,

        // svr or wks

        pszFlavor,

        //domain-neutral"ness" and gc settings - see below.

        STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN | STARTUP_CONCURRENT_GC,

            CLSID_CorRuntimeHost,

        IID_ICorRuntimeHost,

        (void **)&pHost);

 

    // Call default implementation for initialization

    CHttpFilter::GetFilterVersion(pVer);

 

    // Clear the flags set by base class

    pVer->dwFlags &= ~SF_NOTIFY_ORDER_MASK;

 

    // Set the flags we are interested in

    pVer->dwFlags |= SF_NOTIFY_SECURE_PORT | SF_NOTIFY_NONSECURE_PORT |
          SF_NOTIFY_END_OF_NET_SESSION | SF_NOTIFY_END_OF_REQUEST;

 

    // Set Priority

    pVer->dwFlags |= SF_NOTIFY_ORDER_HIGH;

 

    // Load description string

    TCHAR sz[SF_MAX_FILTER_DESC_LEN+1];

 

    ISAPIVERIFY(::LoadString(AfxGetResourceHandle(),

    IDS_FILTER, sz, SF_MAX_FILTER_DESC_LEN));

    _tcscpy(pVer->lpszFilterDesc, sz);

 

    return TRUE;

}

File Attachment: NativeISAPI.zip (558 KB)

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.