2

I am trying to use the ASP.Net AuthenticationService to authenticate users from my Silverlight application. I have a web application, with a service that points to "System.Web.ApplicationServices.AuthenticationService". My web.config has the service, endpoint, binding, behavior, etc defined. For the membership database, I am using SQL Express with an MDF file.

I'm fairly certain all of that is set up correctly because everything works fine if I run it in Visual Studio. My Silverlight app calls into the AuthenticationService, passes in a username and password, and gets back a response.

However, when I deploy to IIS, calling into the AuthenticationService always responds with an exception: "The remote server returned an error: Not Found"

I suspect this has something to do with SQL Express, but haven't been able to pinpoint the problem. I have tried running SQL Express under the System account. I tried giving the Network Services account full permissions to my App_Data folder. I have tried lots of different connection strings.

In any case, can anyone provide any tips or references for how to deploy a Silverlight application using the AuthenticationService with SQL Express and IIS?

Update: I installed the trial version of SQL Server 2008 and have the same results. I can get everything to work fine when running with Visual Studio, but not running in IIS. If anyone has a reference or a tutorial on how to use the AuthenticationService from Silverlight in IIS, I would appreciate it.

Update 2: The problem was with my authentication settings in SQL Server. I was able to track this down by enabling tracing, as suggested in the comments. I have updated the question to be about how to debug problems like this where your service calls work in Visual Studio but not in IIS.

Saeed
  • 287
  • 2
  • 7
  • To note, I wouldn't be so quick to assume the error is at the level of accessing SQL. Are you sure the code got that far? Silverlight doesn't exactly make interoperations cleat cut with its cross-domain policy-ness when you don't know of it. – Grant Thomas Jan 23 '11 at 13:41
  • Read how to add diagnostics to a web.config: http://msdn.microsoft.com/en-us/library/ms733025.aspx. Set switchValue="Error, Critical" and specidy an exception in details. – vortexwolf Jan 23 '11 at 19:54
  • @Mr. Disappointment, I know that if I take authentication out of the picture entirely, my Silverlight app can access my other web services just fine. It only gives me this error when I lock down access to my other services and try to authenticate first. – Saeed Jan 24 '11 at 03:26
  • @vorrtex, thanks for the link. I will give that a try and see if I can get more details on the problem. – Saeed Jan 24 '11 at 03:27
  • @vorrtex, as I indicated in my edit, your suggestion to turn on tracing helped me track down the problem. I changed my question to be about how to debug problems where your WCF calls work in VS but not IIS. Go ahead and post your comment as the answer. – Saeed Jan 24 '11 at 04:26
  • Ok, I've extended the answer in case if someone will get stuck with a similar problem. – vortexwolf Jan 24 '11 at 14:55

1 Answers1

3

For example, I've added this code to the config:

<system.diagnostics>
<sources>
  <source name="System.ServiceModel" switchValue="Critical,Error" >
    <listeners>
      <add name="xml" />
    </listeners>
  </source>
    <source name="System.ServiceModel.MessageLogging" switchValue="Critical,Error">
      <listeners>
        <add name="xml" />
      </listeners>
    </source>
</sources>
<sharedListeners>
  <add initializeData="D:\WcfLog.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="xml" />
</sharedListeners>
<trace autoflush="true" />

A file with the extension "*.svclog" can be opened by Microsoft Service Trace Viewer. Trace Viewer And exceptions are more obvious now.

vortexwolf
  • 13,967
  • 2
  • 54
  • 72