Exception message from WCF call

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
Posts: 1
Joined: Fri May 22, 2020 4:30 am

Exception message from WCF call

Postby sarosigy » Fri May 22, 2020 7:02 am


I'm using a WCF service in my cshtml5 and WPF application.

The service may throw exceptions in some circumstances:

Code: Select all

            if (u == null)
                throw new UnauthorizedAccessException("Invalid membership");

...and it is caught at client side:

Code: Select all

                App.Token = System.Convert.ToBase64String(await App.DashService.AuthenticateAsync(username, password));
            catch (Exception ex)
                await PlatformMessageBox.Show(Localization.GetOf(ex.Message));

The response from the service is like this when logging in with an inappropriate user (from the browser's network window):

Code: Select all

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode><faultstring xml:lang="en-US">Invalid membership</faultstring><detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink i:nil="true"/><InnerException i:nil="true"/><Message>Invalid membership</Message><StackTrace>.........

For different scenarios the message of the thrown exception may vary, and the goal is to display the proper message.

In the WPF application the "Invalid Membership" is the ex.Message, so it works fine.

However, in the cshtml5 application the message is "500 - Internal Server Error", for all scenario. But the fault string is there with the correct message, as it can be seen in the response.
How can I get the fault string in this scenario to display the correct message to the user?

Thank you, in advance,


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 6 guests