I’m creating a simple ASP.NET MVC application and on first run I’m getting blasted with this:
Google didn’t turn up the solution as fast as I would have liked, so I thought I’d post it here for the next fool to find :)
Solution:
When you add a Silverlight project to a solution, Visual Studio will ask you if you would like to create new web site to host it, or choose an existing one in your solution. I choose an existing one. By default, Visual Studio creates this in your HTML markup to host a Silverlight application:
<div id="silverlight">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2">
<param name="source" value="ClientBin/MySilverlightApp.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="autoUpgrade" value="true" />
<param name="initParams" value="page=UserRegistrationView" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" 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>
Visual Studio does not account for the URL rewriting that comes with MVC and by default the path to xap file is wrong. Change the source parameter to be rooted like so:
<param name="source" value="/ClientBin/MySilverlightApp.xap"/>
One simple slash should fix your problem. Hope this helps someone else (you’re not a fool :)