Skip to content
Chen edited this page Sep 2, 2024 · 8 revisions

Listed are some problems you might occur during the journey of development. If you found anything else that could expand this list, feel free to open an issue, or leave me a message on Gitter!

I'm working with a private wiki, and I cannot login to it.

See [MediaWiki] Advanced usages#private-wikis.

Unexpected character encountered while parsing value: <.

Basically this is because WCL receives HTML when it expects JSON response. If it's the first time you come across this exception, please check whether you have used the correct MW API endpoint URL. Note that if the URL provided causes HTTP 301 redirects, client library will usually fail to forward the request to the redirect target (POST request will be converted to GET request, and request body is lost). As for more information, see #38.

HttpRequestException "Could not create SSL/TLS secure channel" when creating WikiSite.

Many sites (including Wikipedia and other WMF projects) requires client to use TLS 1.2 protocol to set up connection. However, TLS 1.2 is not opt-in by the default secure transport configuration before .NET Framework 4.7. (#66) Thus you may need to change the configuration before the first connection is set up to your MediaWiki server.

using System.Net;

ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

Failed: Unable to continue login. Your session most likely timed out.

This is usually related to Cookies not being correctly set up. When you login to a specific MediaWiki site, the server will often drop several session cookies and expect client to send them back when sending further MediaWiki API requests. While the default constructor of WikiClient has manually set HttpClientHandler.UseCookies to true to enable Cookies support, there could be other situations where the Cookies could get lost during communication, such as

  • There is misconfiguration on the MediaWiki server or the reverse proxy, causing the Cookie domain or security policy mismatch.

Login is successful, but you are currently not in "user" group

Whenever after a successful login, WCL will refresh the WikiSite.AccountInfo object. Any non-anonymous user should be inside a built-in "user" group. When you see this assertion failure from Debugger or Warning message from logger, however, it means the freshly-fetched account information indicates the user is not inside the "user" group. This usually means you are no longer logged in when WCL send the second request to fetch account information.

If you have enabled account assertion with SiteOptions.AccountAssertion, your next MediaWiki API request will be very likely to fail.

Such situation could be caused by