开发者

Map all request to one method [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. 开发者_C百科 Closed 10 years ago.

I want to map all request from http://www.mydomain.com/{any url path} to one method and decided to use code below. Unfortunately I get 404, why?

Config file

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.webServer>
    <handlers>
      <add name="Processor" verb="*" path="*.*"
        type="WebClient.Processor,WebClient" />
    </handlers>

    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

Code

namespace WebClient
{

    public class Processor : IHttpHandler
    {

        #region IHttpHandler Members




        public void ProcessRequest(HttpContext context)
        {


         //Read all request here, but never hit

        }



        public bool IsReusable
        {
            // Return false in case your Managed Handler cannot be reused for another request.
            // Usually this would be false in case you have some state information preserved per request.
            get { return true; }
        }

        #endregion
    }
}


Ok, I have found where is the problem. In config file instead of path="." should be path="*"


You need to clear the existing handlers inherited from machine config, if you want to remap paths like *.aspx for instance.

<handlers>
  <clear />
  <add name="Processor" verb="*" path="*" 
                             type="WebClient.Processor,WebClient" />
</handlers>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜