当前位置:首页 > 博客人生 > 技术分享

文章摘要:There is no build provider registered for the extension '.html'. You can register one in the

.net 解决伪静态下,html页面无法访问

发布时间:2023-07-04 作者:小沈子 分类: C#

错误信息:

There is no build provider registered for the extension '.html'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: There is no build provider registered for the extension '.html'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

解决方案:

1、在<system.webServer>节点下添加:

<handlers>
	<add name="GreenHandlers" verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
	<add name="MobileHandlers" verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</handlers>

2、在<compilation debug="true">节点下添加:

<!--URL重写文件设置开始-->
            <buildProviders>
                <add extension=".html" type="System.Web.Compilation.PageBuildProvider" />
            </buildProviders>
<!--URL重写文件设置结束-->


上一篇: C#实现异步的常用方式总结


下一篇: c#中 Exception of type 'System.OutOfMemoryException' was throw的解决办法