Select to view content in your preferred language

publishing Silverlight to IIS

3696
8
09-08-2010 12:41 PM
DaveOrlando
Frequent Contributor
Are there any tutorials / blogs / help topics covering how to publish a Silverlight 4 application to a IIS7 server. No specific questions yet, I'm just looking for some guidance. I have already read that "Publish Web dialog applies only to projects that are created by using the ASP.NET Web Application template". Sounds a little troubling right off the bat.

I also read William Kimrey's thread which was posted today, but haven't even made it as far as he has yet. William, do you have anything you can share?

Thanks in adavance,

(Visual Studio Pro 2010, Silverlight 4, SDK 2.0)
0 Kudos
8 Replies
AliMirzabeigi
Emerging Contributor
0 Kudos
dotMorten_esri
Esri Notable Contributor
0 Kudos
DaveOrlando
Frequent Contributor
Excellent,

Thank you very much.
0 Kudos
WilliamKimrey
Emerging Contributor
Dave,

I hope that you got everything published.  Just in case you haven't, here's all that I ended up having to do.

My main problem was that I was trying to publish from my computer to our production server.  I ended up copying my project to the server on another drive.  So instead of publishing to C:\Inetpub\wwwroot, I published to E:\Applications\Silverlight4.  I then published to IIS from that location using VS2010 and the "File System" where my target location was "http://localhost/MyApp"

Inside IIS i had to make sure that he app was using the correct AppPool (one with .NET 4 Integrated) and that the app's Authentication had "Windows Authentication" and "ASP.NET Impersonation" Enable with the rest Disabled.

I think I did some more tweaking, but I also think I tweaked it back because I spent all day on it.  Looking at the setup now, I think that's all the changes that I left.

Hope that helps, but if you did it another way I'm interested in hearing it.
0 Kudos
DaveOrlando
Frequent Contributor
Hi William, thanks for the reply

My site is an extremely simple test site, so you may have more challenges than I did, but the best advice I read was from Morten.

Basically all a silverlight app requires is:
1) A html page that contains and loads the Silverlight Plugin.
2) A .xap file which is the Silverlight app (this is usual the output in the ClientBin folder of your website when you build it).
3) Optionally (but highly recommended!) the silverlight.js file which helps users install the plugin if they don't already have it.


so all I did was copy the .html and .xap file from my bin/debug to wwwroot/app_folder and bingo, it worked. That was it.

I hope the simplicity of this does not bite me later as my site grows in complexity, but for now I am happy.
0 Kudos
AndrewHargreaves
Deactivated User
Hi,
I need a little help here. It's too simple to be true! Here�??s what I have done:
�?� I have created a virtual directory in IIS, pointing back to C:\...\SilverlightApplication1.Web
�?� I created Test.html, and placed it in C:\...\SilverlightApplication1.Web
�?� Within C:\...\SilverlightApplication1.Web\ClientBin I renamed my *.xap to Test.xap

My thinking is that by hitting http://.../GISSubDisc/GISubDisc_test.html I should get a result, right? But I'm not...

Thanks
0 Kudos
DominiqueBroux
Esri Frequent Contributor
As you renamed the xap file, you have to change the source param in the html file as well.
Something like:
 
<param name="source" value="ClientBin/Test.xap"/>


With this 4th step, it should work.
0 Kudos
JohnMaynard
New Contributor
Hello,
I, too, am having difficulty publishing my Silverlight App.
I created a website inetpub\wwwroot\<SiteName>
I copied the XAP File Called "CorporateHR.XAP" and my one TestPage.HTML File.
Ensured the Website is set to ASP 4.0
I understand double clicking TestPage.HTML should call up the silverlight application on the IIS Server. I get a counter with a circle graphic image and it counts up to 100% and nothing happens.
Do I need to copy any other files or directories over as well ?
How do I get the application to open on the server?
And If I access the URL from a remote computer - what would be the exact URL that I would need to enter in order to access it remotely:
Here are the contents of my TestPage.HTML file:

[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<!-- saved from url=(0014)about:internet -->
<head>
    <title>SurgicalStatusBoard</title>
    <style type="text/css">
    html, body {
     height: 100%;
     overflow: auto;
    }
    body {
     padding: 0;
     margin: 0;
    }
    #silverlightControlHost {
     height: 100%;
     text-align:center;
    }
    </style>
   
    <script type="text/javascript">
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null && sender != 0) {
              appSource = sender.getHost().Source;
            }
           
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;

            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {          
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server" style="height:100%">
    <div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
    <param name="source" value="CorporateHR.xap"/>
    <param name="onError" value="onSilverlightError" />
    <param name="background" value="white" />
    <param name="minRuntimeVersion" value="4.0.50826.0" />
    <param name="autoUpgrade" value="true" />
    <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.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>
    </form>
</body>
</html>
[/HTML]
0 Kudos