I am trying to extract an id number from a URL using a web service so that it can be used as a parameter for a where clause in a select statement that produces data from a database based on the id number of a record. That data will then be passed back to the page to populate an element in a jQuery modal popup widow.
Everything works fine with a static id number (ex: string postid = "120"
), but I don't know how to get the id number from the URL. I'm using Routing in .Net 4 and the method for accessing Routing in pages does not work in a web service. In pages I just do stuff like var id = RouteData.Values["id"];
and that gets the id, but when i did it in a web service I got an error:
CS0120: An object reference is required for the non-static field, method, or property
'System.Web.Routing.RouteData.Values.get'
Summary:
I have web service accessed form a details page where I want to get RouteData
for the page making the request. I want to do this just as easily as I can on a page using RouteData.Values
which is just as easy as the now the obsolete Request.Querystring
.
Now I am more confused because although I could easily add a new route for the web service I don't know I would call that using jQuery Ajax because of the webservice.asmx/webmethod syntax.
Right now I have URL: "../webservices/googlemaps.asmx/GetGoogleMap" in my jQuery Ajax, but that is not a real URL. It only exists in jQuery somewhere and the way to call the service using just JavaScript is no a real URL either, its webservice.webmethod()
which in this case would be googlemaps.GetGoogleMap()
.
I will try registering a route for webservices/googlemaps.asmx/GetGoogleMap/postid
, but I doubt it will work because GetGoogleMap
is not a directory or a querystring
.