I was looking for a high low and still can not find a specific answer.
How to configure IIS 7.0 or a web application in IIS so that ASP.NET Runtime processes all requests, including static ones, for example, *.js , *.gif , etc.
I am trying to do the following.
We have a SaaSy website that we can "strum" for each client. βBrandingβ means developing a custom homepage and using a bunch of *.css and other images.
It is only natural that I use VirtualPathProvider , which works as follows:
public override System.Web.Hosting.VirtualFile GetFile(string virtualPath) { if(PhysicalFileExists(virtualPath)) { var virtualFile = base.GetFile(virtualPath); return virtualFile; } if(VirtualFileExists(virtualPath)) { var brandedVirtualPath = GetBrandedVirtualPath(virtualPath); var absolutePath = HttpContext.Current.Server.MapPath(brandedVirtualPath); Trace.WriteLine(string.Format("Serving '{0}' from '{1}'", brandedVirtualPath, absolutePath), "BrandingAwareVirtualPathProvider"); var virtualFile = new VirtualFile(brandedVirtualPath, absolutePath); return virtualFile; } return null; }
The main idea is this: we have a branding folder inside our webapp, which, in turn, contains folders for each "brand", and the "brand" is equal to the host name. That is, requests from http://foo.example.com/ should use static files from branding/foo_example_com , while http://bar.example.com/ should use content from branding/bar_example_com .
Now what I want to do IIS is to forward all requests for static files to StaticFileHandler , which will then use all this "infrastructure" and serve the correct files. However, try as I could, I cannot configure IIS for this.