gpt4 book ai didi

.net - ASP.NET 的自定义文件扩展名 - 需要帮助!

转载 作者:行者123 更新时间:2023-12-01 05:40:11 25 4
gpt4 key购买 nike

我让 modaspdotnet 在我的 Apache 2.2 服务器上运行,因此它可以很好地运行 ASP.NET 和 MySQL。

但是,我想做的是提供具有其他扩展名的内容,而不仅仅是默认的 .aspx,例如myfile.custom 扩展名。

在 Apache 中,我相信它是通过 .htaccess 完成的,但在 ASP.NET 中它是通过 web.config 完成的。

这是我的 web.config 文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
</system.web>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".testing1" mimeType="application/x-asp-net " />
</staticContent>
</system.webServer>

</configuration>

它确实有效,但 ASP.NET 代码无法正确呈现 - 我希望能够使用任何自定义扩展来运行 ASP.NET 代码。

已安装 IIS 和 NET 3.5。

我不想运行完整的 IIS 服务器,但我正在做的项目确实需要 ASP.NET,因此是 Apache 的 modaspdotnet 附加组件。

这是我的 httpd.conf 的最后一行,表示安装 modaspdotnet:
    LoadModule aspdotnet_module modules/mod_aspdotnet.so

# Use the asp.net handler for all common ASP.NET file types
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj \
licx rem resources resx soap vb vbproj vsdisco webinfo
<IfModule mod_aspdotnet.cpp>
# For all virtual ASP.NET webs, we need the aspnet_client files
# to serve the client-side helper scripts.
AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
<Directory "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
Options FollowSymlinks
Order allow,deny
Allow from all
</Directory>
</IfModule>
#asp.net
AddType application/x-asp-net .asp
AddType text/html .asp
AddHandler application/x-httpd-php .asp

为什么这对我不起作用,我应该怎么做才能解决这个问题?
我环顾了网络,但找不到太多......有什么想法吗?

最佳答案

简单地添加 mime 类型是不够的 - 页面不会被解释,而只是流式传输到浏览器。
我对 apache 了解不多。但是通常当您想要提供普通的 aspx 页面但具有不同的扩展名时,您必须:

  • 在自定义扩展名下添加默认的 aspx httphandler,如下所示:

  •  <httpHandlers>
    ...
    <add verb="*" path="*.mycustomextension"> type="System.Web.UI.PageHandlerFactory"/>

  • 注册构建提供者:

  • <compilation >
    <buildProviders>
    <add extension=".mycustomextension" type="System.Web.Compilation.PageBuildProvider" />
    </buildProviders>


    尝试一下,也许这会为您指明正确的方向

    关于.net - ASP.NET 的自定义文件扩展名 - 需要帮助!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6004213/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com