This topic was posed on my web site, so I thought I might move it here in case anyone else had the same question ..... here is the chain ....
-----------------------------------------
Larry D on 12.30.2008 at 4:55 PM
Hi John, everyone else:
following the ADO.Net Data Services (chpt 11) approach, I'd like to add a service that returns the current user identity from the server.
In NorthwindDataService.svc.cs (EFDataServices)
I thought I could just add
[WebGet]
public string CurrentUser()
{
return HttpContext.Current.User.Identity.ToString();
}
However it does not show up, I'm assuming due to it not being IQueryable.
Is there a recommended approach to adding services such as this to the ado.net data services? The example in the book for CustomersByCity is IQueryable.
thanks,
-Larry
-----------------------------------------
Larry D on 12.30.2008 at 7:38 PM
Hi John,
the WebGet CustomersByCity doesn't appear to be working for me (from chapter 11 EFDataServices NorthwindDataService.svc.cs). I get 404 resource not found when trying as per the inline doc.
Also when browsing to NorthwindDataService.svc, should CustomersByCity appear with the other endpoints listed? No errors when compiling, and I'm using the code as downloaded.
suggestions?
thanks,
-Larry
-----------------------------------------
John Papa on 12.30.2008 at 9:40 PM
Larry,
The CustomersByCity method will not appear as a proxy method explictly. Instead, it is accessible via a RESTful URI off of the EntityContainer. For example:
http://localhost:8890/NorthwindDataService...#39;London' This will invoke the CustomersByCity method in the service.
You would also need to allow permission to the web method using this line of code (which I commented out in the sample code, so you can just uncomment it )
config.SetServiceOperationAccessRule("CustomersByCity", ServiceOperationRights.All);
Finally, make sure Customers entityset is accessible by doing this:
config.SetEntitySetAccessRule("Customers", EntitySetRights.AllRead);