views:

561

answers:

5

I'm just meddling in the ways of the RESTful web service in C# using ASP.Net 2.0 and have managed (via a class library, a reference to dll produced by the former and some adjustment of my web.config) to coax out a URI format like so:

http: //localhost/DevelopmentProject/testhandler/?input=thisismyinput

Which unremarkably just returns the input as a piece of text with the enlightening prefix "Your Input Was: "

I was under the impression that I could get the URI to become further ensmoothened to something more along the lines of:

http: //localhost/DevelopmentProject/testhandler/thisismyinput

and have the same result but have no idea how to get rid of the pesky "?input="

The entry to the httphandlers section of my web.config is (spaces added so code displays):

< add verb="*" path="testhandler/*" type="HandlerLib.testhandler, HandlerLib"/ >

I am running IIS 5.1 on the local machine, will this introduce a problem?

Essentially where am I going wrong?

Thanks.

A: 

You could implement URL rewriting, using something like URLRewriter.net That would let you use the syntax you've mentioned.

Darksider
+1  A: 

One solution is to use UrlRewriting to rewrite the Url to what you need.

I use http://urlrewriter.net/ to do all my rewriting, and you could setup something like this in your scenario

<rewriter>
   <rewrite 
     url="DevelopmentProject/testhandler/([\w]+)" 
     to="DevelopmentProject/testhandler/?input=$1" />
</rewriter>

This would remain "http: //localhost/DevelopmentProject/testhandler/thisismyinput" in your browser address bar, yet process as "http: //localhost/DevelopmentProject/testhandler/?input=thisismyinput"

WebDude
A: 

I kinda cheated.

Try:

My Article About How I Got Round It

A: 

Change your config from: < add verb="" path="testhandler/" type="HandlerLib.testhandler, HandlerLib"/ > to: < add verb="" path="testhandler/*" type="HandlerLib.testhandler, HandlerLib"/ >

I've just realised someone came in and edited my question so it was asked wrong. What a fool. I'm editing it back.
A: 

Check out the value of Request.PathInfo in your handler's ProcessRequest function with a URL like http://localhost/DevelopmentProject/testhandler/thisismyinput.

If that doesn't do it, make sure that IIS 5.1 is routing ALL requests to the aspnet_isapi.dll. (Although, it seems like it already is) This is the "Configuration..." button > "App Mappings" tab in your virtual directory in IIS.

Jeff Meatball Yang