I wanted rounded corners, but with minimal fuss. I'm using border-radius and variants (-moz, -webkit, -khtml) which is great, except for on IE, but I found a DHTML behavior (
http://code.google.com/p/curved-corner/) that makes it so IE will appear to have these powers. The trouble is, I'm using SiteFinity which, like any good CMS, has these virtual folders that don't exist in IIS and url references to behaviors must be in the same directory.
To fix this, I wrote a quick HttpHandler to all me to capture requests for htc files and serve them from any path.
Here's the source:
public class HtcAnywhereHandler : IHttpHandler
{
public HtcAnywhereHandler() { }
public bool IsReusable { get { return false; } }
public void ProcessRequest(HttpContext context)
{
FileInfo fi = new FileInfo(context.Server.MapPath("~/htc/" + context.Request.Url.Segments[context.Request.Url.Segments.Length - 1]));
if (fi.Exists && fi.Extension.Equals(".htc", System.StringComparison.InvariantCultureIgnoreCase))
{
context.Response.ContentType = "text/x-component";
context.Response.BinaryWrite(File.ReadAllBytes(fi.FullName));
}
else
context.Response.StatusCode = 404;
}
}So now I have an /htc directory where I really store my behavior but a request to /skljfsfcio/border-radius.htc will serve the /htc/border-radius.htc file. Yay.
To make this work, you'll need to add an entry to the httpHandlers section in the web.config
<add verb="GET" path="*.htc" validate="false" type="HtcAnywhereHandler, HtcAnywhere" />
Then you need to tell IIS to use ASP.NET for .htc files. Go to the web site properties, Home Directory tab, [configuration...], add an application extension to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll for .htc, Limit to: "GET", and turn off verify that it exists.
The bummer for me was that in my html that border-radius.htc didn't end up working. Sigh.