Hosting Silverlight with IIS 6 / SQL data retrieval problem
Last post 05-13-2008 2:12 PM by caramba. 12 replies.
Sort Posts:
05-07-2008 11:14 PM
Hosting Silverlight with IIS 6 / SQL data retrieval problem

Hi.  I've been googling this problem for hours, and have gone through most of the forum questions trying to find the answer to my problem.

I have a silverlight application, which is as basic as they come - it has a text box that asks you for a video title.  If you put in a title, or even the beginning letter of the file name, and then click "search", it queries a SQL database and the results are delivered into a data grid.  It runs perfectly on my local development workstation (through visual studio '08).  However, when I try to host it with IIS (I have tried this on both my local workstation and the live web server), the initial front-end of my application appears (which is being called from a .xaml), but as soon as I click the "Search" button, it takes me to a blank page.  So I know that the .xaml is fine, otherwise, I wouldn't be able to see the text box and search button. 

I have registered MIME types for .xap, .xaml and .xbap in IIS.  I can download the .xap file from the URL.  Everything I have read keeps pointing back to registering the .xap file.  But that doesn't seem to be the problem in this case. 

I have even gone so far as to putting the application on the same server as the SQL database, as I thought authentication was the problem originally.  And maybe it still is, I'm not sure.  I created an account for the anonymous access in IIS, and gave that account the proper permissions in SQL as well.  Am I missing a step, as far as the authentication goes? (I'm using windows authentication).

This is driving me nuts.  So if anyone could help me out here, I would be forever grateful!!!!

Jess

jessbryant

Joined on 05-08-2008
Posts 5
05-08-2008 9:41 AM
Re: Hosting Silverlight with IIS 6 / SQL data retrieval problem

If silverlight become blank, it's due to an exception not handled in silverlight. I think your web service is not working on IIS or you forgot to redirect the webservice url in silverlight. When you add a WebService in visualstudio, the url is hard coded in the generated cs file. If you create it without changing this default url, it will try to access your development server and not your IIS server.

Thierry Bouquain
Ucaya
http://www.ucaya.com

thierry.bouquain

Joined on 05-06-2007
Nantes, France
Posts 224
05-08-2008 9:43 AM
Re: Hosting Silverlight with IIS 6 / SQL data retrieval problem

You can trace the webservice call with web development helper (http://www.codeplex.com/webdevhelper) in internet explorer

Thierry Bouquain
Ucaya
http://www.ucaya.com

thierry.bouquain

Joined on 05-06-2007
Nantes, France
Posts 224
05-08-2008 11:49 AM
Re: Hosting Silverlight with IIS 6 / SQL data retrieval problem

Hi. Thank you for replying.  I'm obviously a complete newb when it comes to this.  You are correct in that I did not change the default url when I added the WebService.  You said it's hard coded in the generated cs file.  I'm assuming you are referring to the reference.cs file?  If so, I went in and changed it from http://localhost:port to my server's URL/virtualdirectory and I'm still getting the same thing.  The front end of my application appears, I put in a parameter in the search box, click the search button and it takes me to a blank page.  I installed the Web Development Helper, and as soon as I hit my application the results come back with 2 items:

URL: http://serverURL/videoLibrary/SQLvideoTestPage.html (the serverURL being the proper site url)
Status:  200
Response Size: 1,823

URL: http://serverURL/videoLibrary/ClientBin/SQLvideo.xap
Status:  200
Response Size: 239,301

Then, when I enter in a parameter in the search box, and click the search box the WebDev Helper log doesn't change.

Do you have any other suggestions?

 

jessbryant

Joined on 05-08-2008
Posts 5
05-08-2008 11:52 AM
Re: Hosting Silverlight with IIS 6 / SQL data retrieval problem
Oh, and one more thing...when I test this in IE, the blank page status at the bottom says "Done".  But when I test it in Firefox, it goes to a blank page, but the page status says:  "Transferring data from URL......." (URL being the URL of the page).  And if refresh the page, it takes me back to the front-end of my application, then when I try the search again, the status now says "Done" on the blank page.
jessbryant

Joined on 05-08-2008
Posts 5
05-08-2008 12:00 PM
Re: Hosting Silverlight with IIS 6 / SQL data retrieval problem

The browser status does not reflect silverlight status. It's really strange that you do not see your web service url in the web dev helper. It means that your application is crashing before silverlight emits its web request. It will be hard for me to guess what is happening...

Thierry Bouquain
Ucaya
http://www.ucaya.com

thierry.bouquain

Joined on 05-06-2007
Nantes, France
Posts 224
05-08-2008 12:03 PM
Re: Hosting Silverlight with IIS 6 / SQL data retrieval problem

So it must be an IIS thing.... I have tested this on 2 different web servers running IIS, as well as my local workstation running IIS.  And as I said earlier, it runs fine when I run it through the Web development of Visual Studio (on my local workstation).  Hmmmm.......

Do you think it could be a permissions thing between IIS and SQL?

jessbryant

Joined on 05-08-2008
Posts 5
05-08-2008 3:12 PM
Marked as Answer
Re: Hosting Silverlight with IIS 6 / SQL data retrieval problem
Well, low and behold, it was a SQL server permissions problem.  I changed the connection string in the web.config file to connect via SQL authentication.  That fixed it.  Now I just need to figure out a way to change that.  That's definately not secure.  But at least now I know there's nothing wrong with my application.
jessbryant

Joined on 05-08-2008
Posts 5
05-12-2008 6:42 AM
Re: Hosting Silverlight with IIS 6 / SQL data retrieval problem

I have the same problem but connect to mySQL. Could  jessbryant please  write how to change the connection string in the web.config (sample)?

caramba

Joined on 05-12-2008
Posts 3
05-13-2008 4:37 AM
Re: Hosting Silverlight with IIS 6 / SQL data retrieval problem

caramba:
I have the same problem but connect to mySQL. Could  jessbryant please  write how to change the connection string in the web.config (sample)?
 

Connectionstring with SQL authentication.

connectionString="Server=MyServer; Database=pubs; User Id=MyUser; password= P@ssw0rd"
Connectionstring with Windows Authentication
connectionString="Server=MyServer;Database=MyDb;Trusted_Connection=Yes;"
OR 
connectionString="Initial Catalog=MyDb;Data Source=MyServer;Integrated Security=SSPI;" 

 

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlsync

Joined on 09-16-2005
Singapore
Posts 2,021
05-13-2008 6:15 AM
Re: Hosting Silverlight with IIS 6 / SQL data retrieval problem

I don't get it. web.config is a  xml file. In web-service i have:

MySqlConnection myConnection = new MySqlConnection();
myConnection.ConnectionString = "Persist Security Info=False;database=bugtracker1;server=localhost;Connect Timeout=30;user id=root; pwd=123";
        myConnection.Open();

Do you mean this line or i need place it in web.config at tag <connectionStrings/>?

Solution consists of web site with asmx service and silverlight app with DataGrid, MIME types added to IIS 6.0.

Thanks a lot!

caramba

Joined on 05-12-2008
Posts 3
05-13-2008 10:12 AM
Re: Hosting Silverlight with IIS 6 / SQL data retrieval problem

caramba:
i need place it in web.config at tag <connectionStrings/>?

Yes.  

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlsync

Joined on 09-16-2005
Singapore
Posts 2,021
05-13-2008 2:12 PM
Re: Hosting Silverlight with IIS 6 / SQL data retrieval problem

Blank page is gone, page loads,datagrid is visible without data then error on page:

Error: Sys.InvalidOperationException: ManagedRuntimeError #4002 in control 'Xaml1': System.Exception:[AsyncCallbackException]

Web-service works fine on IIS.

I think the problem with call to  GetDataCompleted()

if //  line 10 thare are the error on page else empty datagrid

 void ta_GetDataCompleted(object sender, Silverlight.ServiceReference1.GetDataCompletedEventArgs e)
        {
       line 10  //   if (e.Error == null)     

                   displayData(e.Result);

}

HELP!

caramba

Joined on 05-12-2008
Posts 3