简体   繁体   English

为ASP.NET MVC5视图引擎注册自定义文件扩展名

[英]Register custom file extension for asp.net mvc5 view engine

How can I register custom file extension for ASP.NET MVC view engine? 如何为ASP.NET MVC视图引擎注册自定义文件扩展名? In default ASP.NET MVC using file extensions: cshtml, vbhtml, aspx and I want to add my own. 在默认的ASP.NET MVC中,使用文件扩展名:cshtml,vbhtml,aspx,我想添加自己的扩展名。

I found some solutions, but there are out of date - doesn't work in nowadays or there are uncomplete - some step(s) is(are) missing for reproduce... 我找到了一些解决方案,但是这些解决方案已经过时-如今不起作用或不完整-缺少一些可复制的步骤...

Here's how to register a new mime type in the web.config (edit: seeing your comment this may not do the trick but you asked so here's the details for future reference): 这是在web.config中注册新的mime类型的方法(编辑:看到您的评论可能不会成功,但您要求这样做,所以这里有详细信息,以备将来参考):

...
   <system.webServer>
        <staticContent>
              <mimeMap fileExtension=".myext" mimeType="text/html" />
        </staticContent>
    </system.webServer>
</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM