There are two ways to deploy the XAP file in SharePoint environment.
1, We can use SharePoint default location [\Templates\Layouts\ClientBin] and deploy the file there. Refer this location from the Silverlight web part.
2, We can use a SharePoint document library and deploy the file there. Refer this document library location file path while adding the silverlight web part.
Firstly,we will use the default location to deploy
- To deploy and test the code in SharePoint 2010 we need to use the SharePoint Silverlight web part [New web part added in this version].
- The silverlight web part default location is "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin". So, all the XAP files should be deployed to this location to use them in the silverlight web part.
- To make this process easier, we need to do below.
- Right click on Silverlight project -> propertiese -> Build -> change the output path to "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin".
- Build the solution and see the XAP generated in the ClientBin location.
- Now, navigate to SharePoint site where you want to see the silverlight data, Edit page.
- Add silverlight web part to the page.
- It will prompt you for the XAP file location: Type the url: "/_layouts/ClientBin/SP2010Silverlight_HelloWorld.xap".
- Now click on OK and you can see the silverlight web part on the page.