Net.Urlify 1.0.1

dotnet add package Net.Urlify --version 1.0.1                
NuGet\Install-Package Net.Urlify -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Net.Urlify" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Net.Urlify --version 1.0.1                
#r "nuget: Net.Urlify, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Net.Urlify as a Cake Addin
#addin nuget:?package=Net.Urlify&version=1.0.1

// Install Net.Urlify as a Cake Tool
#tool nuget:?package=Net.Urlify&version=1.0.1                

Net.Urlify

Net.Urlify is a lightweight and powerful NuGet package designed to simplify the construction of URLs with query parameters in .NET applications. It provides a clean and fluent way to append query string parameters to URLs using property attributes.

Features

  • Attribute-based Query Parameters: Define query parameters directly on model properties using the QueryStringPropertyAttribute, including control over the order in which parameters appear in the URL.
  • Automatic URL Encoding: Automatically handles the URL encoding of query parameters, unless explicitly stated otherwise.
  • Flexible URL Construction: Seamlessly construct URLs with base paths and append query parameters dynamically extracted from object properties.

Getting Started

Usage

  1. Define Your Model

    Start by decorating your model's properties with the QueryStringPropertyAttribute to specify which properties should be included as query string parameters, and optionally specify their order:

using Net.Urlify.Attributes;

public class MyModel
{
    [QueryStringProperty("user", false, 2)]
    public string Username { get; set; }

    [QueryStringProperty("age", true, 1)]
    public int Age { get; set; }
}

In the above model, Username and Age are marked as query parameters. Username will use "user" as the query parameter name and will not be URL-encoded. The order property ensures that "user" appears before "age" in the URL query string.

  1. Inherit from Urlify

    Inherits from Urlify and defines a base URL. This class will use the properties of your model to build the full URL.

public class MyModel : Urlify
{
    [QueryStringProperty("user", false, 1)]
    public string Username { get; set; }

    [QueryStringProperty("age", true, 2)]
    public int Age { get; set; }

    public MyModel(string baseUrl) : base(baseUrl) { }
}
  1. Construct the URL

    Call the BuildUrl() method to construct your URL:

var model = new MyModel("http://example.com")
{
    Username = "John Doe",
    Age = 28
};

var url = model.BuildUrl(); // Outputs: http://example.com?user=John%20Doe&age=28
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 618 6/12/2024
1.0.0 131 6/6/2024