I have implemented my own IRouteHandler for URL routing.
For files without extension it will try to load the filename as a Page from the Pages directory with:return (IHttpHandler) BuildManager.CreateInstanceFromVirtualPath(path, typeof(Page));
How开发者_如何学运维ever there are also images and css files (with relative paths) that need to be translated to the correct url. I try to service those files with:
try {
HttpContext.Current.Server.Transfer(fileName);
} catch (HttpException) {
throw new HttpException(404, "file not found");
}
This works fine (in Internet Explorer), however Firefox is giving me an error:
Styles.css was not loaded because its MIME type, "text/html", is not "text/css".
Is this caused by the Server.Transfer?
What should I use to redirect the file? Response.Redirect is visible to the client.I've found a solution, .NET 3.5 and IIS7 introduced a new method: Server.TransferRequest
.
With the TransferRequest method the request is sent back through the IIS pipeline. http://msdn.microsoft.com/en-us/library/aa344902.aspx
Firefox is happily accepting my CSS files again.
精彩评论