views:

99

answers:

2

I have a basic hosting package that gives me access to create a MySQL database. I can of course host silverlight applications on any site. But how can I work with a database from within Silverlight? I cannot run any service on my hosting provider, they only allow php or perl scripts.

+1  A: 

You can use the C# webclient to make HTTP calls to a PHP page hosted on the server. The PHP page can proxy queries/results between the silverlight client and the mysql database.

remember, just because it's not a SOAP/WCF "service" does not mean that it's not a web service. Look into PHP based REST solutions for some nice alternatives that can easily be invoked via silverlight:
http://www.bing.com/search?q=PHP+REST

Edit: As @Spencer Ruport correctly points out in the comments, you of course have to be wary of the fact that the web service will be exposed to the public, and anyone can easily sniff the http traffic between your silverlight application and the server. This enable them to call your service directly so be sure to think about authentication and what it means in the context of your app/data

Joel Martinez
You also might want to mention that access to this service can be detected by users and accessed directly so various security concerns regarding such open access to db data should be taken into careful consideration.
Spencer Ruport
In IIS we use web forms security which rides inside the Session, and then enabled all of our web services with session compatibility and check to make sure we have an authenticated user for the call, and then apply additional application security in the web service call. You users will still be able to sniff that traffic, but they won't be able to use that data to make unauthenticated or unauthorized calls. Its been a long time since I have been in PHP land, but it has the equivalent of Sesion, right? These are basically the same web service concerns you have in Javascript.
Jason Jackson
Yeah of course, PHP supports session and whatever other authentication scheme you might require :-)
Joel Martinez
A: 

You can use the WebClient class in silverlight to communicate to a php service. Here is the first google result I found: link

mdm20