Hi,

I am trying out with a simple URL redirection technique; if I am successful in this approach I will go ahead in implementing friendly RESTful urls for my application.

Problem I am facing in URL redirection using Http Handler:

I have created a VisualStudio2008 webservcie application.
Added 2 services, Service1.asmx and Service2.asmx.

Scenario 1:
Added an Http Handler (GenericHandler) class in the same hierarchy.
Added the below code in ProcessRequest method,

if (context.Request.PhysicalPath.IndexOf("Service1.asmx") > -1)
context.RewritePath("~/Service2.asmx");

Registerd the Handler in the httpHandler section of the webconfig, the bold one

<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
<add verb="*" type="RESTWS.RESTHandler,RESTWS" path="*.asmx"/>

Now, I run my application by making Service1.asmx as the start page, the process hits my handler code, executes it with out any expection, but atlast I see a blank screen in the browser.

For crossing my code I also did the following,
Scenario 2:
Added a Global.asax file in the in the same hierarchy.
Added same code in Application_BeginRequest

if (Context.Request.PhysicalPath.IndexOf("Service1.asmx") > -1)
Context.RewritePath("~/Service2.asmx");

Commented out the Handler registry part what I added in the webconfig.
Again ran the application, the redirection from Service1.asmx to Service2.asmx happened successfully as expected.

Scenario 3:
When I have both the Global.asax and the httphandler enabled, again I get a blank page.

Scenario 4:
I felt that httpHandler doesnot suppport url redirection in the case of asmx(webservices), so I tried the same above procedures and scenarios with VisualStudio2008 Web application with 2 aspx pages (Default1.aspx and Default2.aspx) instead of Web service application. But the results were same as the above scenarios.

My Questions:

What is the mistake I am doing in my above scenarios?
How to perform urlredirection for web services using Http Handlers?



Thanks in Advance.