Repository navigation
Getting Started
In a project:
dotnet add package IsImageUrlDotNetor in the project file:
<PackageReference Include="IsImageUrlDotNet" Version="2.0.0" />In a .NET 10 file-based app, #:package IsImageUrlDotNet@2.0.0; in an F# script, #r "nuget: IsImageUrlDotNet, 2.0.0". The examples on this wiki were run through those two directives. dotnet add package and a PackageReference restore the same package but were not run for this wiki.
The package depends on FSharp.Core 6.0.7 or later, so a C# project gets FSharp.Core through it without adding anything. In the C# apps that ran these examples, with no other F# package, NuGet picked FSharp.Core 6.0.7.
The package holds three builds with the same public surface. The verification program printed which one each app loaded:
| App's target | Build loaded | Ran on |
|---|---|---|
| net10.0 | lib/net10.0 |
.NET 10.0.12, Windows and Linux |
| net48 | lib/net462 |
.NET Framework 4.8.9345.0, Windows |
| net8.0 | lib/netstandard2.0 |
.NET 8.0.23, Windows |
.NET Framework 4.6.2 to 4.7.2, Mono, Unity and Xamarin can load the net462 or netstandard2.0 build but were not tested. On .NET Framework, the net462 build brings its System.Net.Http reference with it.
The two methods are extension methods on string and also plain static methods on ImageUrl. The examples assume implicit usings, which SDK-style projects for .NET 6 and later turn on; a .NET Framework project needs using System;, using System.Net.Http;, using System.Threading; and using System.Threading.Tasks; at the top.
using IsImageUrlDotNet;
bool offline = ImageUrl.HasImageExtension("photos/cat.PNG?w=1");
bool online = await ImageUrl.IsImageUrlAsync("http://images.test/about");
Console.WriteLine($"{offline} {online}");prints:
True False
The stand-in answered /about with text/html, so the online answer is false. Without an HttpClient of yours, the package uses one shared client with a 10-second timeout. To use your own client, its handler, proxy and headers, pass it, with a token if you want one:
using IsImageUrlDotNet;
using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(3));
Console.WriteLine(await "http://images.test/avatar".IsImageUrlAsync(client, cts.Token));prints:
True
These three examples printed the same on .NET 10, .NET Framework 4.8 and .NET 8.
In a script:
#r "nuget: IsImageUrlDotNet, 2.0.0"
open IsImageUrlDotNet
printfn "%b" (ImageUrl.HasImageExtension "https://example.com/photos/cat.PNG?w=200")
printfn "%b" ("photos/cat.png".HasImageExtension())
let isImage =
ImageUrl.IsImageUrlAsync("http://images.test/avatar")
|> Async.AwaitTask
|> Async.RunSynchronously
printfn "%b" isImageprints:
true
true
true
F# can call HasImageExtension and IsImageUrlAsync in the extension form, as the second line does. It cannot call the old url.IsImageUrl() that way; see the FAQ. Inside task { }, let! awaits IsImageUrlAsync directly (Recipes).
How URLs are checked says exactly when each method answers true. Edge cases and errors covers what can go wrong.
This wiki describes IsImageUrlDotNet 2.0.0 and was last updated on 2026-09-29. The library is MIT licensed. Report problems in the issues. On NuGet: IsImageUrlDotNet.
Using it
The releases
Contributing
Elsewhere