Orchard Web应用程序内的虚拟目录 [英] Virtual directory inside Orchard web application

查看:107
本文介绍了Orchard Web应用程序内的虚拟目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Orchard Web应用程序中有一个/downloads文件夹,我可以将客户端定向到该文件夹​​中,以便他们可以下载文件. www.mydomain.com/downloads/test.txt

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

在IIS中,我在Orchard网站下方创建了一个虚拟目录(不是应用程序),该目录指向服务器上的downloads文件夹.

In IIS I have created a virtual directory (not an Application) underneath the Orchard website that points to the downloads folder on the server.

在Orchard Global.ascx文件中,我添加了以下内容,认为这是路由问题:

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
}

不能100%确定是否需要这样做.

Not 100% sure if this is required.

但是,当我去下载文件www.mydomain.com/downloads/test.txt时,我仍然收到404错误.

However, when I go to download the file, www.mydomain.com/downloads/test.txt, I continue to receive a 404 error.

推荐答案

感谢此帖子,找到了此修复程序: http://orchard .codeplex.com/discussions/280041

Found the fix thanks to this post: http://orchard.codeplex.com/discussions/280041

首先,它必须是Orchard网站下的应用程序,而不仅仅是虚拟目录.在IIS中,您可以右键单击虚拟目录>转换为应用程序.

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.

此后,问题在于Orchard中的web.config传播到子应用程序.要停止此操作,您需要在Orchard的web.config文件的<system.web><system.webserver>节点周围添加<location path="." inheritInChildApplications="false">.您可以在位置标签此处了解更多信息.

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.

进行了这些更改之后,我可以毫无问题地成功下载我的test.txt文件.

After making those changes, I can then successfully download my test.txt file with no problems.

这篇关于Orchard Web应用程序内的虚拟目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆