开发者

IIS 7 handler mapings & asp.net *.htm page routing with WebForm. How to route *.htm like *.aspx?

开发者 https://www.devze.com 2023-02-22 20:12 出处:网络
I am trying to make the *.htm files processable by .net to route this extension, but I am unable until now. I search through tons of results on google/bing, I found something to make the mapping and t

I am trying to make the *.htm files processable by .net to route this extension, but I am unable until now. I search through tons of results on google/bing, I found something to make the mapping and to route it, but it's not working. Note that I am using webForm, not mvc.

The mapping set in IIS is Managed Handler : path=*.htm, Handler=System.Web.UI.SimpleHandlerFactory Here the code I am using.

Am I miss开发者_如何学Cing something?

Thanks!

//Web.config

<system.web>

    <httpModules>

        <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModue,System.Web.Routing,Version=4.0.0.0,Culture=neutral, PublicKeyToken=31BF3856AD364E35" />   

</httpModules>

<httpHandlers>

  <add verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler,System.Web, Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" />

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

 </httpHandlers>

</system.web>

<system.webServer>

  <validation validateIntegratedModeConfiguration="false" />

  <modules runAllManagedModulesForAllRequests="true">

  <remove name="UrlRoutingModule"/>

  <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule,System.Web.Routing,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31BF3856AD364E35" />

  </modules>

  <handlers>

    <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

  </handlers>

</system.webServer>

//global.asax.cs

void RegisterRoutes(RouteCollection routes){

        routes.Ignore("{ressources}.asd/{*pathInfo}");

        routes.MapPageRoute("OnlineHelp", "Help/Content/{HelpFile}.htm", "~/Default.aspx");

        routes.MapPageRoute("Default", "", "~/Default.aspx",true);

    }
0

精彩评论

暂无评论...
验证码 换一张
取 消