2015-02-10 55 views
1

注册HTTP处理程序在我创造了这个HTTP处理程序一把umbraco项目

public void ProcessRequest(HttpContext context) 
     { 
      //write your handler implementation here. 
      string RequestedPage = context.Request.Url.Segments[1].ToString().ToLower(); 
      string queriedRequest = "category1-page"; 
      bool doesUrlContain = RequestedPage.Equals(queriedRequest); 

      if (doesUrlContain) 
      { 
       context.Response.Redirect(context.Request.Url.Segments[0] + "production" + context.Request.Url.Segments[2]); 
      } 
     } 

的应处置每次调用“测试页”或及其子页面,并通过改变URL的一部分重定向。 但是,我不清楚如何在我的umbraco项目中注册这个处理程序。也许有人可以提供一步一步的教程?

此处理程序应该在用户使用旧页面或子页面的链接时运行,并在根页面更改时重定向到正确的页面。

本地我使用iis7进行开发。

感谢您的转发。

回答

1

在你的web.config,你需要添加引用您的类在其中定义HTTP处理程序,像这样的处理程序:

<system.webServer> 
    <handlers> 
     <add name="MyHandler" path="test-page" verb="*" type="MyNamespace.MyHandlerClass" resourceType="Unspecified" preCondition="integratedMode" /> 

的HTTP处理程序必须在同一程序被定义为web.config。