How to fully validate a URL in C# .NET Framework

Cloudmersive
1 min readJul 14, 2020

--

URL validation is there to save the day when dealing with potential broken links or even malicious site submissions. Today we will be implementing just such a system, but we will be breaking all kinds of records because it’s only going to take 5 minutes. You read correctly. Now continue reading to get to those juicy results ASAP.

We will first need to grab our package from NuGet.

Install-Package Cloudmersive.APIClient.NET.Validate -Version 3.0.6

Now it’s time to call our function as you see right here:

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.Validate.Api;using Cloudmersive.APIClient.NET.Validate.Client;using Cloudmersive.APIClient.NET.Validate.Model;namespace Example{public class DomainUrlFullExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new DomainApi();var request = new ValidateUrlRequestFull(); // ValidateUrlRequestFull | Input URL requesttry{// Validate a URL fullyValidateUrlResponseFull result = apiInstance.DomainUrlFull(request);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling DomainApi.DomainUrlFull: " + e.Message );}}}}

Enter in the URL and it will be checked syntactically, the server queried, and a virus scan will be performed on the target page. Easy.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet