I have an Umbraco site on the root. It's working fine.
I need to be able to serve static (not ASP.NET) content from IIS, eg /foo. (/foo maps to a different folder structure than the main app, eg:
www.example.com -> d:\sites\example.com
www.example.com/foo -> d:\sites\static\foo
www.example.com/bar -> d:\sites\static\bar
I can setup an IIS application, but then I inherit the parent applications web.config, and as this is static content, it has none of the dlls etc needed (and shouldn't have them!)
I can setup an IIS virtual directory, and add in the various bits into the web.config to tell Umbraco NOT to use the folder (umbracoReservedUrls, umbracoReservedPaths). This works, however it is still running as the main ASP.NET application, and I'd much prefer it to be only static (ie, no .NET runtime allowed)
Neither is ideal, as we may have a few of these, so will need to script all the creation. Editing 4 web.config files (in a web cluster) isn't ideal.
What I'd like is:
Everything I search for comes up with a "nope, can't be done". Did I miss something?
Just to clarify, I'm not needing a CDN — we have one. I just want to have /foo to be it's own folder, with a bunch of html/css/images (eg /foo/index.html, /foo/images/logo.png), which are served up to the user, but not via umbraco — just via IIS.
There are three steps to requesting static content from a server: A user sends a request for a file to the web server. The web server retrieves the file from disk. The web server sends the file to the user.
ASP.NET Core application cannot serve static files by default. We must include Microsoft. AspNetCore. StaticFiles middleware in the request pipeline.
Static files are files that clients download as they are from the server. Create a new directory, public. Express, by default does not allow you to serve static files. You need to enable it using the following built-in middleware.
On your second suggestion in the question, you could tell IIS to disallow script access.
I've just had to do something similar to this as a quick-fix for something needing SSL hosting for a few days at work, so I did:
Put the code in its own folder inside an Umbraco site.
Made the folder be its own application:
(source: serverintellect.com)
(I could have disabled Execute permissions here, had I wanted to, from the drop-down box reading "Scripts only" in the screenshot above, but I actually need execute permissions for my quick-fix.)
Added a minimal Web.config to override the bits of the Umbraco Web.config that I didn't want:
<configuration>
<system.web>
<httpModules>
<clear/>
</httpModules>
<httpHandlers>
<clear/>
<add path="*.aspx" verb="*"
type="System.Web.UI.PageHandlerFactory" validate="true"/>
<add path="*" verb="GET,HEAD,POST"
type="System.Web.DefaultHttpHandler" validate="true"/>
<add path="*" verb="*"
type="System.Web.HttpMethodNotAllowedHandler" validate="true"/>
</httpHandlers>
</system.web>
</configuration>
(These handlers were copied directly from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config
on my laptop)
There is no step five.
Quick — and very dirty — but it works ;o)
maybe a little bit ugly, but could you create a symlink into your umbraco root folder and just serve it as if it were a regular folder? (Maybe also adding the path to the umbracoReservedPaths setting in the web.config)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With