需要帮助 - 自定义文件扩展名的ASP.NET! [英] Custom file extensions for ASP.NET - help needed!

查看:248
本文介绍了需要帮助 - 自定义文件扩展名的ASP.NET!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有modaspdotnet工作我的Apache 2.2的服务器上,因此它运行ASP.NET和MySQL pretty的好。

不过,我想要做的就是服务了内容与其他扩展不仅仅是默认的.aspx,例如: myfile.customextension。

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

这是我的web.config文件:

 < XML版本=1.0编码=UTF-8&GT?;
<结构>
  <的System.Web>
  < /system.web>
    < system.webServer>
        < staticContent>
            <testing1mimeMap fileExtension = MIMETYPE =应用程序/ x-ASP网/>
        < / staticContent>
    < /system.webServer>

< /结构>
 

它的工作,但ASP.NET code不正确渲染 - 我希望能够与任何自定义扩展运行ASP.NET code

IIS和.NET 3.5的安装。

我不希望运行一个完整的IIS服务器,但确实需要ASP.NET的一个项目我做,因此modaspdotnet附加的Apache。

这是我的httpd.conf的最后一行标志着modaspdotnet的安装:

 的LoadModule aspdotnet_module模块/ mod_aspdotnet.so

#使用asp.net处理程序所有常见的ASP.NET文件类型
AddHandler的asp.net ASAX ASCX ASHX ASMX ASPX AXD配置CS的csproj \
                   licx REM资源RESX肥皂VB vbproj vsdisco webinfo
< IfModule mod_aspdotnet.cpp>
  #所有的虚拟ASP.NET网,我们需要的aspnet_client文件
  #以服务客户端辅助脚本。
  Alias​​Match /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*)C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP .NETClientFiles / $ 4
  <目录C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles>
    有FollowSymLinks
    订购允许,拒绝
    所有允许
  < /目录>
< / IfModule>
#asp.net
将AddType应用程序/ x-ASP网的.asp
将AddType text / html的的.asp
AddHandler的应用程序/ X的httpd  -  PHP的.asp
 

为什么这个工作不适合我,我应该怎么做才能解决此问题? 我周围的网一看,也没有找到太多...任何想法?

解决方案

简单添加MIME类型是不够的 - 网页是不是有兴趣的朋友PTED $ P $,而只是传输到浏览器。 我不知道很多关于Apache。但通常,当你想为正常的aspx页面,但不同的扩展,你必须:

  1. 添加默认的aspx的HttpHandler根据自定义的扩展是这样的:

 < HttpHandlers的>
...
<加上动词=*路径=* mycustomextension。> TYPE =System.Web.UI.PageHandlerFactory/>
 

  1. 注册生成提供:

 <编译>
      < buildProviders>
          <添加扩展名=类型=System.Web.Compilation.PageBuildProvider/&GTmycustomextension。
      < / buildProviders>
 

试试吧,也许这将指向你在正确的方向。

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?

解决方案

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:

  1. Add your default aspx httphandler under custom extension like this:

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

  1. Register build provider:

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

Try it out maybe this will point you in the right direction

这篇关于需要帮助 - 自定义文件扩展名的ASP.NET!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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