I would like to have a /downloads folder inside an Orchard web app where I can direct clients to so they can download files ie. www.mydomain.com/downloads/test.txt
In IIS I have created a virtual directory (not an Application) underneath the Orchard website that points to the downloads folder on the server.
In the Orchard Global.ascx file, I've added the following, thinking that it was a routing problem:
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("downloads/{*pathInfo}"); // added this IgnoreRoute
}
Not 100% sure if this is required.
However, when I go to download the file, www.mydomain.com/downloads/test.txt, I continue to receive a 404 error.
A virtual directory is a directory name (also referred to as path) that you specify in Internet Information Services (IIS) 7 and map to a physical directory on a local or remote server.
For example, you might use a virtual directory when you want your application to include images from another location in the file system, but you do not want to move the image files into the physical directory that is mapped to the application's root virtual directory. By default, IIS uses configuration from Web.
Right-click the Web site that you want (for example, Default Web Site), point to New, and then click Virtual Directory. On the Welcome to the Virtual Directory Creation Wizard page, click Next. On the Virtual Directory Alias page, type the alias that you want (for example, Sales), and then click Next.
Found the fix thanks to this post: http://orchard.codeplex.com/discussions/280041
Firstly, it needed to be an application under the Orchard website, rather than just a virtual directory. In IIS you can right click on the virtual directory > convert to Application.
After that, the issue is that the web.config in Orchard propagates to the child applications. To stop this, you need to add <location path="." inheritInChildApplications="false">
around both the <system.web>
and <system.webserver>
nodes in Orchard's web.config file. You can read more on the location tag here.
After making those changes, I can then successfully download my test.txt file with no problems.
Brilliant, thank you so much for this answer. After implementing it straight off here my Orchard styles broke, but after having a look at that link, I noticed this bit of code:
<location path="Themes">
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers accessPolicy="Script">
<remove name="StaticFile" />
</handlers>
</system.webServer>
</location>
<location path="Core">
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers accessPolicy="Script">
<remove name="StaticFile" />
</handlers>
</system.webServer>
</location>
<location path="Media">
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers accessPolicy="Script">
<remove name="StaticFile" />
</handlers>
</system.webServer>
</location>
<location path="Modules">
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers accessPolicy="Script">
<remove name="StaticFile" />
</handlers>
</system.webServer>
</location>
Which will fix your Orchard style, for anyone having that issue.
It should be placed in the web.config file in the root of your site, just before the <runtime>
and after the last </location>
that you will have just added to finish wrapping <system.webServer>
.
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