Orchard Web 应用程序内的虚拟目录

发布于 2025-01-07 06:52:41 字数 550 浏览 0 评论 0 原文

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

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

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

public static void RegisterRoutes(RouteCollection routes) {
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.IgnoreRoute("downloads/{*pathInfo}"); // added this IgnoreRoute
}

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

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

2025-01-14 06:52:41

感谢这篇文章找到了修复: http://orchard.codeplex.com/discussions/280041

首先,它需要是Orchard网站下的一个应用程序,而不仅仅是一个虚拟目录。在IIS中你可以右键单击虚拟目录>转换为应用程序。

之后,问题是 Orchard 中的 web.config 传播到子应用程序。要阻止这种情况,您需要添加 节点周围继承InChildApplications="false">。您可以在此处了解有关位置标记的更多信息。

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

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.

烟柳画桥 2025-01-14 06:52:41

太棒了,非常感谢您的回答。直接在这里实现后,我的 Orchard 样式就崩溃了,但是在查看该链接后,我注意到了这段代码:

<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>

对于任何遇到该问题的人来说,这将修复您的 Orchard 样式。

它应放置在站点根目录下的 web.config 文件中,位于您将要执行的 之前和最后一个 之后刚刚添加完成包装

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>.

方圜几里 2025-01-14 06:52:41

您不一定需要破解果园下的配置。
对于我来说,在类似的情况下,在虚拟目录下创建一个包含以下内容的 web.config 就足够了:

<configuration>
<system.webServer>
<handlers accessPolicy="Read, Script">
    <clear />
    <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Script" />
</handlers>
</system.webServer>

You don't necessarily need to hack the config under orchard.
In a similar situation for me there was enough to create a web.config under the virtual directory with the following content:

<configuration>
<system.webServer>
<handlers accessPolicy="Read, Script">
    <clear />
    <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Script" />
</handlers>
</system.webServer>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文