如何更改.Net页面将在其下运行的扩展名?

时间:2022-11-25 03:45:14

I need my .net application to use the .html extension instead of .aspx

我需要我的.net应用程序来使用.html扩展名而不是.aspx

I'm converting a php app and there are external applications which depend on that extension to function.

我正在转换一个php应用程序,并且有外部应用程序依赖于该扩展功能。

What is the best way to do this?

做这个的最好方式是什么?

Thanks

4 个解决方案

#1


12  

In IIS, when you create the application for the virtual directory, click on "Configuration" for the application, and edit "App mappings", i.e. add a new mapping for html.

在IIS中,为虚拟目录创建应用程序时,单击应用程序的“配置”,然后编辑“应用程序映射”,即为html添加新映射。

Or, in your web.config, in add this sections:

或者,在您的web.config中,添加以下部分:

<httpHandlers>
   <remove verb="*" path="*.html" />
   <add verb="*" path="*.html" type="System.Web.UI.PageHandlerFactory" />
</httpHandlers>
<compilation>
   <buildProviders>
       <buildProvider 
           extension=".html" 
           type="System.Web.Compilation.PageBuildProvider" />
   </buildProviders>
</compilation>

EDIT: Added the section, according to the comment. Thanks Chris.

编辑:根据评论添加了部分。谢谢克里斯。

#2


1  

You want to use httpHandlers

您想使用httpHandlers

#3


0  

Note that I am not 100% sure this will work with the PHP extension, we are using this procedure for a custom extension here.

请注意,我不是100%确定这将适用于PHP扩展,我们在此处使用此过程进行自定义扩展。

You can change the IIS configuration: Open the IIS Console (right click on My Computer > Manage... > Services and applications)

您可以更改IIS配置:打开IIS控制台(右键单击“我的电脑”>“管理...”>“服务和应用程序”)

  • If you are in a website, open the websites properties and the "Home directory" tab.
  • 如果您在网站中,请打开网站属性和“主目录”选项卡。

  • If you are in a virtual directory, the properties then the "Virtual Directory" tab.
  • 如果您位于虚拟目录中,则属性将显示“虚拟目录”选项卡。

Click The "Configuration Button", look up the .aspx extension and use the same configuration for the ".php" extension (tip: you can copy paste the executable dll name between both dialogs)

单击“配置按钮”,查找.aspx扩展名并对“.php”扩展名使用相同的配置(提示:您可以复制粘贴两个对话框之间的可执行DLL名称)

#4


0  

Some time ago, we migrated a web application from coldfusion to PHP, and had to preserve the old URLs. The way we did it was to use mod_rewrite to rewrite .cfm URLs to .php ones. Perhaps you can do something similar?

前一段时间,我们将一个Web应用程序从coldfusion迁移到PHP,并且必须保留旧的URL。我们这样做的方法是使用mod_rewrite将.cfm URL重写为.php。也许你可以做类似的事情?

#1


12  

In IIS, when you create the application for the virtual directory, click on "Configuration" for the application, and edit "App mappings", i.e. add a new mapping for html.

在IIS中,为虚拟目录创建应用程序时,单击应用程序的“配置”,然后编辑“应用程序映射”,即为html添加新映射。

Or, in your web.config, in add this sections:

或者,在您的web.config中,添加以下部分:

<httpHandlers>
   <remove verb="*" path="*.html" />
   <add verb="*" path="*.html" type="System.Web.UI.PageHandlerFactory" />
</httpHandlers>
<compilation>
   <buildProviders>
       <buildProvider 
           extension=".html" 
           type="System.Web.Compilation.PageBuildProvider" />
   </buildProviders>
</compilation>

EDIT: Added the section, according to the comment. Thanks Chris.

编辑:根据评论添加了部分。谢谢克里斯。

#2


1  

You want to use httpHandlers

您想使用httpHandlers

#3


0  

Note that I am not 100% sure this will work with the PHP extension, we are using this procedure for a custom extension here.

请注意,我不是100%确定这将适用于PHP扩展,我们在此处使用此过程进行自定义扩展。

You can change the IIS configuration: Open the IIS Console (right click on My Computer > Manage... > Services and applications)

您可以更改IIS配置:打开IIS控制台(右键单击“我的电脑”>“管理...”>“服务和应用程序”)

  • If you are in a website, open the websites properties and the "Home directory" tab.
  • 如果您在网站中,请打开网站属性和“主目录”选项卡。

  • If you are in a virtual directory, the properties then the "Virtual Directory" tab.
  • 如果您位于虚拟目录中,则属性将显示“虚拟目录”选项卡。

Click The "Configuration Button", look up the .aspx extension and use the same configuration for the ".php" extension (tip: you can copy paste the executable dll name between both dialogs)

单击“配置按钮”,查找.aspx扩展名并对“.php”扩展名使用相同的配置(提示:您可以复制粘贴两个对话框之间的可执行DLL名称)

#4


0  

Some time ago, we migrated a web application from coldfusion to PHP, and had to preserve the old URLs. The way we did it was to use mod_rewrite to rewrite .cfm URLs to .php ones. Perhaps you can do something similar?

前一段时间,我们将一个Web应用程序从coldfusion迁移到PHP,并且必须保留旧的URL。我们这样做的方法是使用mod_rewrite将.cfm URL重写为.php。也许你可以做类似的事情?