Is there a way to call Silverlight method from Asp.net MVC4 controllder? -
i need call silverlight method mvc4 application controller.
i load silverlight using object tag,
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="50%" height="100%" style="border:1px solid #cdcdcd"> <param name="source" value="clientbin/helloworld.xap"/> <param name="onerror" value="onsilverlighterror" /> <param name="background" value="white" /> <param name="minruntimeversion" value="5.0.61118.0" /> <param name="autoupgrade" value="true" /> <param name="onload" value="pluginloaded" /> <a href="http://go.microsoft.com/fwlink/?linkid=149156&v=5.0.61118.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?linkid=161376" alt="get microsoft silverlight" style="border-style:none"/> </a> </object><iframe id="_sl_historyframe" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
and call silverlight method, i'm using js method.
but want call silverlight method mvc4-controllder.
is possible? if so, how should do?
please advice me.
//silverlight method [scriptablemember] public void showalertpopup(string message) { messagebox.show(message, "message javascript", messageboxbutton.ok); }
that impossible. silverlight runs on client javascript, while mvc runs on server. these different machines.
if need reuse method, use either of:
- source code sharing (section 'adding existing item link')
- portable library project
- ria services shared code features
if thing need reusing couple of methods, suggest moving them separate file , linking file 2 projects (a mvc project , silverlight project).
one important note can reuse code uses features present both in silverlight , .net. can't use silverlight-specific features (e.g. browser interaction) mvc application.
if need send messages server client, have implement either of:
- polling
- long polling
- server-sent events
- websockets
signalr great library simplifying task.
Comments
Post a Comment