Sunday, September 23, 2007

WebResource and Behaviors

I'm currently developing a custom WebControl and got stuck in a problem: my carefully crafted behavior didn't work as a Embedded Resource.

Well... let's dissect this:

  1. I created a behavior file for use with Internet Explorer (*.htc);
  2. Added this file as an Embeded Resource to my Assembly;
  3. Added the WebResource attribute to my assembly pointing to the HTC file;
  4. Made the reference to the HTC file using the
    GetWebResourceUrl function; and
  5. BANG! Nothing happened.

After a few tests and some poking around on the net, I finally discovered what I did wrong.

When I wrote the WebResource attribute in the AssemblyInfo file, I put "text/plain" as the MIME-type for the HTC file.

To the HTC file work correctly it requires the "text/x-component" MIME-type.

After I put the right MIME-type, the behavior worked perfectly, as it was supposed to.

0 Comments:

Post a Comment