I am new to programming and F# is my first language. I am currently still very unfamiliar with .NET APIs.
I want to write a function that, given a specific URL, will return TRUE if the HTTP status code is 200, and will return FALSE if it is 404.
Here is the code I have written:
open System.Net
let checkIfUrlIsValid (url: string) =
try
let webRequest = HttpWebRequest.Create(url)
let webRequest.Method = "HEAD"
use webResponse = webRequest.GetResponse()
webResponse.StatusCode = HttpStatusCode.OK
with
:? System.Net.WebException -> false
However, I get the following error message:
The namespace or module 'HttpWebRequest' is not defined
What went wrong? What changes should I make?
Aucun commentaire:
Enregistrer un commentaire