I'm developing an application with Silverlight 3 and ASP.NET Web Services, which uses Linq to SQL to get data from my SQL Server database.
Randomly when the user causes an action to get information from any of my web service methods, Silverlight throws the exception "The remote server returned an error: NotFound.", of type "CommunicationException", with the InnerException status of "System.Net.WebExceptionStatus.UnknownError".
Almost 10% of requests gets this error. If the user tries to get the same information again, normally the request has no errors and the user gets the data.
When debugging in Visual Studio only Silverlight stops on the exception, and I see no reason for the web service not being found.
The problem you're seeing is because the web service does not return any details about the exception to the silverlight client whenever any exception occurs. It just returns a 404 not found status as the result and hence you always get the exception "Not Found".
What you can try and do is make sure your web service returns a 200(valid result) even in case of exception and somehow returns the error message along with the object.
example:
public class WebServiceResult
{
//your object's properties go here
//extra properties to check if exception has occured
public string ErrorMessage {get; set;}
public bool IsError {get; set;}
}
Use Fiddler to try and better understand what i'm saying. You'll see a 404 error in case of every exception.
if you happen to be using WCF web services, you might try turning on WCF Tracing in your web.config file:
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\CodePlex.Diagnostics\CodePlex.Diagnostics.Services.Web.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
For context and details: READ ME!
As far as I know WebClient treats all errors as a "404". If you can switch the code to use HttpClient instead you will get more verbose errors. If that code is buried (or generated) then Fiddler will be your best bet.
Related
I’ve been asked to make changes to an existing MVC website, unfortunately the original developer of this site is no longer at the company, there isn’t any documentation and nobody actually knows much about it other than it current runs in our test & live environments. groan
Anyway when I set the project as the starting project and run it I get the following lovely white error page:
Access is denied.
Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.
Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server's administrator for additional assistance.
Not a massive amount for me to go on (for me at least).
So I checked in the web.config file and the authorization is set as:
<authorization>
<deny users=”?” />
</authorization>
If I change this to the code below I get a page saying it couldn’t be loaded, but it is a step further as I can at least get into the code a little.
<authorization>
<allow users="*"/>
</authorization>
The code does do some validation against Active Directory, which works, and I can get around that pesky security code by setting a break point and moving past the functionality. The code itself doesn’t do anything but return true if the user is valid (I move the breakpoint to this), or false if they are invalid. This is the only way I have been able to catch a breakpoint within my controller to see if anything happens, but nothing sticks out.
The code, as partial as it may be, is in a class which will use LINQ to get the right information.
public ReadOnlyCollection<Application> GetApplicationStatus()
{
using (ApplicationDBEntities context = new ApplicationDBEntities())
{
var results = (from parameters in context.Parameters
join application in context.ApplicationIds on parameters.ApplicationId equals application.ApplicationId1
where parameters.ParameterName.Equals("DateTime", StringComparison.OrdinalIgnoreCase) &&
!parameters.Application.Equals(0)
select new Application
{
ApplicationId = parameters.ServiceId,
ApplicationStatus = application.Status,
DateAdded = parameters.ParameterValue
}).ToList();
return new ReadOnlyCollection<Application>(results);
}
}
In the above code it will throw an EntityException when getting the results, the message in the exception is “The underlying provider failed on Open.” The specific line highlighted is var results = (from parameters in context.Parameters
With this I figured that either the code current live isn’t the same as what I have (hopefully not the case) or something else was up, which is when I spotted the Inner Exception message: Login failed for user 'NT AUTHORITY\\ANONYMOUS LOGON'.
The connection string is as follows:
<connectionStrings>
<add name="ApplicationDBEntities" connectionString="metadata=res://*/ApplicationDBModel.csdl|res://*/ApplicationDBModel.ssdl|res://*/ApplicationDBModel.msl;provider=System.Data.SqlClient;provider connection string="data source=MyServer;initial catalog=MyDB;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
The SQL database that it is trying to get the information from is one that I have direct access to. Could this be that the IIS account doesn’t have access or something? Are there any tips or hints to try and find the root cause of this problem?
In your connection string there is intergated security = true, that means that your site try to get data from sql with authentication as user that runs application pool of IIS.
So you should run your iis application pool by user that have rights on db and, may be, on on other resources of your site.
Another possibility is that there is sql user to go to db an you should change connection string in config file.
I've developed .an application using Silverlight and WCF Ria Services.
The application must be host on windows XP machine that uses IIS 5. Due the information i found on web I did deploy application without any problems. But now when my application tries to execute first WCF query I've faced this error :
Message: Unhandled Error in Silverlight Application Load operation
failed for query 'Login'. [HttpWebRequest_WebException_RemoteServer]
Arguments: NotFound Debugging resource strings are unavailable. Often
the key and arguments provide sufficient information to diagnose the
problem. See
http://go.microsoft.com/fwlink/?linkid=106663&Version=5.1.10411.0&File=System.Windows.dll&Key=HttpWebRequest_WebException_RemoteServer
at
System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception
error) at
System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation.End(IAsyncResult
result) at
System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation.<>c_DisplayClass1.b_0(Object
state) at
System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation.RunInSynchronizationContext(SendOrPostCallback
callback, Object state) at
System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation.HandleAsyncCompleted(IAsyncResult
asyncResult) at
System.ServiceModel.DomainServices.Client.AsyncResultBase.Complete()
at
System.ServiceModel.DomainServices.Client.ApplicationServices.WebAuthenticationService.HandleOperationComplete(OperationBase
operation) at
System.ServiceModel.DomainServices.Client.LoadOperation.<>c_DisplayClass41.<Create>b__0(LoadOperation1
arg) at
System.ServiceModel.DomainServices.Client.LoadOperation`1.InvokeCompleteAction()
at
System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception
error) at
System.ServiceModel.DomainServices.Client.LoadOperation.Complete(Exception
error) at
System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult
asyncResult) at
System.ServiceModel.DomainServices.Client.DomainContext.<>c_DisplayClass1b.b__17(Object
)
How can I fix this error ?
Application hosted successfully on IIS 7 on windows 7 machine and wcf ria did work too.
Update : After using Fiddler I found my application's error is 404 , Silverlight can't find Ria Services .
NotFound means any error on the server in this case. You need to get detailed WCF logs.
I'd recommend you to add the following to the web.config file to enable WCF logging:
<configuration>
... your regular configuration here ...
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="All" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener"
initializeData="C:\wcflogs\your_wcf_service_log.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
Then you can open .svclog file with Service Trace Viewer Tool (SvcTraceViewer.exe)
and see what happened in detail.
Try to re install RIA Services on server.
I think the command was
RiaService.msi Server=true
after reinstalling, try to access your service directly on web browser. the URL of your Service will be http://YOURDOMAIN.COM/YourAPP/Full-NameSpace-Of-Class.svc
in the namespace, you will have to change dots (.) by dashes(-)
if it doesn't return response, then you have to verify that WCF is installed and registered with IIS.
I'm having problems to find enough information to figure out what's missing on my published Silverlight application.
Running the applicaton locally (but with the db connectionstring to the "live" database), everything is running fine.
However, when I try to run at the published remote site it fails. It seems to be related to the db connection, but I don't get any detailed error from the server.
I've added a "debug" code at RIA service completed method
if (myLoadOperation.HasError)
{
MessageBox.Show(myLoadOperation.Error.Message);
MessageBox.Show(myLoadOperation.Error.InnerException.ToString());
}
The messagebox displays:
Load operation fail for the query 'GetData'. The remote server returned an error : NotFound
What is not found??!?
Additional information I get from JIT Debugger (VS2010)
NotFound. at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception error)
I suspect that it might be a dll related to EF or RIA which may be missing on the remote server, but I'm not quite sure how to identify what's wrong. It's a shared hosting environment.
Could it be located to the MySQL provider?
connectionString="metadata=res://*/Model.Model1.csdl|res://*/Model.Model1.ssdl|res://*/Model.Model1.msl;provider=MySql.Data.MySqlClient;provider connection string="server=xxxxxxxxx;User Id=xxxxxxx;password=xxxxxxxxx;Persist Security Info=True;Allow Zero Datetime=True;Convert Zero Datetime=true;database=xxxxxxxxxx;" providerName="System.Data.EntityClient"
I've uploaded the following dll's to the server's bin folder:
System.ServiceModel.DomainServices.EntityFramework.dll
System.ServiceModel.DomainServices.Hosting.dll
System.ServiceModel.DomainServices.Hosting.OData.dll
System.ServiceModel.DomainServices.Hosting.Server.dll
I found the blog post WCF RIA Services - “Not Found” Error Message to offer several methods of debugging this very generic error message. Using tools like Fiddler and WCF Binary-encoded Message Inspector for Fiddler should give you a better understanding of what the real error message is.
I have a SL navigation application, that currently runs on a shared hosting package with a 3rd party ISP. I can login, and register using the ASP.NET membership and role providers.
I have now setup a dedicated server, on which only my app will run. It does not yet have a domain name that points to it... I access it via an IP address.
I've copied the entire site (including the ClientBin and all the XAP's) to the new server, but the Authentication and Registration services don't work... they just return NotFound.
When I check Fiddler on the working site, this service is called :
www.myaddress.com/ClientBin/MyApp-Web-AuthenticationService.svc/binary/Login
which of course succeeds. However, on the other site, the fiddler trace looks the same (because I just copied the site) :
123.123.123.123/ClientBin/MyApp-Web-AuthenticationService.svc/binary/Login
but, the call fails with NotFound. Fiddler reports it as HTTP/1.1 500 Internal Server Error. When I open
http://localhost/ClientBin/MyApp-Web-AuthenticationService.svc/binary/Login
on the server, I get the HTTP/1.1 500, as well as this description :
Handler "svc-Integrated" has a bad module "ManagedPipelineHandler" in its module list
Which leads me to believe that there is something wrong with my IIS config, as the exact same code is working on another system.
What is a "bad module"? How do I fix it?
Normally this type of error is that ASP.Net is not activated or that a handler for svc is not registered or registered correctly.
In your case is looks a bit different. It could be that you have .net framework 4.0 code that you are trying to run in a .net framework 2.0 application pool.
IIS 500 errors often show up with more information in the Windows Event log - if you can somehow get access to that?
Also I've noticed that often the server will actually send debugging output back to the client that everything seems to ignore. Have you checked the entire raw response that is coming back from the server to see if there are any clues there?
I have a Silverlight app that I developed locally, and I'm trying to run it on a Windows 2008 R2 server that I personally setup. Everything smooth and dandy, except that when I try to auth on the app, it tries to look locally for
http://localhost/crossdomainpolicy.xml
http://localhost/clientaccesspolicy.xml
It also throws a nasty error :
Uncaught Error: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at SomeService.MVServiceReference.CheckUserCompletedEventArgs.get_Result()
at SomeService.Pagini.Autentificare.AuthForm.webServiceSoapClient_CheckUserCompleted(Object sender, CheckUserCompletedEventArgs e)
at SomeService.MVServiceReference.MVWebServiceSoapClient.OnCheckUserCompleted(Object state)
If your XAP file is on http://localhost/somewhere/somefile.xap it shouldn't look for a clientaccesspolicy. Are you using the ASP.NET dev. server to host the Silverlight app while you are using IIS for a WCF service that is called by the silverlight app?
Silverlight's inability to present exception details is well known. It is due to the fact that all communication from a Silverlight component to a service utilizes the hosting browser and when there is an error returned with a http error code, the browser only returns the error code and not the message containing the exception details to silverlight.
Activate WCF trace logging on the server side and look in the svc-log to get the real exception message.
For crossdomain purposes, http://localhost/ , http://localhost:1234/ and http://localhost:4321/ are all different domains.