Path of Web Service
pertaining silverlight applications use data web service, has tried overriding path of service in xaml , accessing code? it seems me our group going need in order move from through the dev/test/prod process.
ok, want change webservice path depending on develpment mode, testing mode or in production. can use init parameters , web.config file. this,
have appsetting in web.config file
<appsettings> <add key="serviceuri" value=http://localhost/yourwebservice.svc/> </appsettings>in code behind file of aspx page host silvelright control(say xaml1), , assign initparameter of sl control this,
protected sub page_load(byval sender as object, byval e as system.eventargs) xaml1.initparameters = "serviceuri=" & configurationmanager.appsettings("serviceuri") end subgo app.xaml.vb(or .cs) file , write application_startup event this,
private sub application_startup(byval o as object, byval e as startupeventargs) handles me.startup serviceuri = e.initparams("serviceuri").tostring() if string.isnullorempty(serviceuri) then dim host as string = application.current.host.source.host dim port as string = application.current.host.source.port if port = "80" then port = "" serviceuri = "http://" & host & iif(string.isnullorempty(port), "", ":" & port) & "/webservice_folder/yourwebservice.svc" end if me.rootvisual = new page() end sub
and thats it, if don't pass argument service uri application construct webservice path, otherwise use passed parameter value.
Silverlight > Hosting and Streaming with Silverlight
Comments
Post a Comment