ASP.NET 的自定义文件扩展名 - 需要帮助!
我的 Apache 2.2 服务器上运行了 modaspdotnet,因此它可以很好地运行 ASP.NET 和 MySQL。
然而,我想做的是提供具有其他扩展名的内容,而不仅仅是默认的 .aspx,例如 myfile.customextension。
在 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
为什么这对我不起作用,我应该做什么来解决这个问题? 我浏览了网络,但找不到太多......有什么想法吗?
I've got modaspdotnet working on my Apache 2.2 server, and as such it runs ASP.NET and MySQL pretty well.
However, what I'd like to do is serve up content with other extensions than just the default .aspx, e.g. myfile.customextension.
In Apache, I believe it's done via .htaccess, but in ASP.NET it's done via the web.config.
This is my web.config file:
<?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>
It DOES work, but the ASP.NET code doesn't render properly - and I want to be able to run ASP.NET code with any custom extension.
IIS and NET 3.5 are installed.
I don't want to run a full IIS server but do need ASP.NET for a project I'm doing, hence the modaspdotnet add-on for Apache.
This is the final line of my httpd.conf signifying the install of 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
Why is this not working for me, and what should I do to resolve this?
I had a look around the net, but couldn't find too much... any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单地添加 mime 类型是不够的 - 页面不会被解释,而只是流式传输到浏览器。
我对阿帕奇了解不多。但通常当您想要提供普通的 aspx 页面但具有不同的扩展名时,您必须:
尝试一下也许这会给你指明正确的方向
Simple adding mime type is not enough - page is not interepreted but simply streamed to the browser.
I don't know much about apache. But normally when you want to serve normal aspx page but with different extension you have to:
Try it out maybe this will point you in the right direction