Skip to content
m4bwav edited this page Sep 30, 2026 · 1 revision

Does it download the image?

No. IsImageUrlAsync sends a GET, reads the status and headers, and disposes of the response without reading the body. HasImageExtension sends nothing. Neither checks that the bytes are an image (Edge cases and errors).

Why is IsImageUrlAsync("avatar.png") false when HasImageExtension("avatar.png") is true?

IsImageUrlAsync takes absolute http and https URLs only, and answers false for anything else before looking at the extension. HasImageExtension also reads relative paths. Use HasImageExtension for file names (How URLs are checked).

Can F# call url.IsImageUrl()?

No. F# reads the old module's F# signature and ignores its C# extension attributes:

#r "nuget: IsImageUrlDotNet, 2.0.0"
open IsImageUrlDotNet

printfn "%b" ("image.png".IsImageUrl())

fails with:

fs-old-extension.fsx(4,27): error FS0039: The type 'String' does not define a field, constructor, or member named 'IsImageUrl'. Maybe you want one of the following:
   IsImageUrlAsync

Write IsImageUrlDotNetLib.IsImageUrl url, or better, use the new methods, which F# can call in either form (Getting started).

Why does url.IsImageUrlAsync(default) not compile?

default fits both the CancellationToken and the HttpClient overloads, so C# reports CS0121. Pass CancellationToken.None, a token or a client (API reference).

Which proxy does it use?

The shared client uses the process's default proxy. On .NET 10 and .NET 8 that includes the HTTP_PROXY and HTTPS_PROXY environment variables, which .NET Framework ignores; there, WebRequest.DefaultWebProxy applies. Every online example on this wiki reached its local stand-in that way. On .NET 10, .NET 8 and in F# scripts it went through the variables. On .NET Framework, WebRequest.DefaultWebProxy was set before the example ran. For another proxy, pass your own client.

What User-Agent does it send?

The shared client sends IsImageUrlDotNet/2.0 (+https://github.com/m4bwav/IsImageUrlDotNet). Your own client sends its own headers and none from the package (Recipes).

Can I call it from many threads at once?

Yes. The concurrent recipe runs three calls at once on the shared client.

How long can a call take?

With the shared client, up to 10 seconds for each request, and a check that follows redirects sends up to 11 requests. Pass a token for a shorter deadline (recipe).

Is it safe for URLs from untrusted users?

Not on its own: it requests loopback and private addresses and follows redirects to other hosts. Pass a client whose handler refuses those addresses and has AllowAutoRedirect = false, and never use the obsolete IsImageUrl for such input (Edge cases and errors).

Does it run on .NET Framework 4.6.2?

The package has a net462 build, and that build ran here on .NET Framework 4.8 with the same answers as .NET 10. .NET Framework 4.6.2 to 4.7.2 themselves were not tested.

My 1.x code started warning. Must I change it?

No. IsImageUrl still builds and gives 1.0.2's answers; the warning says it is obsolete. Versions and upgrading shows which answers change when you move to the new methods.