Sidio.OpenGraph.AspNetCore
2.0.0
Prefix Reserved
dotnet add package Sidio.OpenGraph.AspNetCore --version 2.0.0
NuGet\Install-Package Sidio.OpenGraph.AspNetCore -Version 2.0.0
<PackageReference Include="Sidio.OpenGraph.AspNetCore" Version="2.0.0" />
<PackageVersion Include="Sidio.OpenGraph.AspNetCore" Version="2.0.0" />
<PackageReference Include="Sidio.OpenGraph.AspNetCore" />
paket add Sidio.OpenGraph.AspNetCore --version 2.0.0
#r "nuget: Sidio.OpenGraph.AspNetCore, 2.0.0"
#:package Sidio.OpenGraph.AspNetCore@2.0.0
#addin nuget:?package=Sidio.OpenGraph.AspNetCore&version=2.0.0
#tool nuget:?package=Sidio.OpenGraph.AspNetCore&version=2.0.0
Sidio.OpenGraph
Sidio.OpenGraph is a .NET library for creating OpenGraph tags. Both .NET Standard 2.0 and .NET 8+ are supported.
Sidio.OpenGraph | Sidio.OpenGraph.AspNetCore | |
---|---|---|
NuGet | ||
Requirements | .NET Standard 2.0 | .NET 8+, AspNetCore |
ASP .NET Core support
Sidio.OpenGraph.AspNetCore provides the same functionality as Sidio.OpenGraph, but it has some helper functions to make it easier to use in an ASP.NET Core application. This library can be used in .NET 8 or higher applications only.
Installation
Get this package on NuGet:
Usage
Dependency injection
Dependency injection is recommended over creating instances of OpenGraphBuilder
directly. The
AddOpenGraph
extension method on IServiceCollection
registers the following services:
IOpenGraphBuilderFactory
: factory for creatingOpenGraphBuilder
instances.IObjectPoolService<OpenGraphBuilder>
: object pool forOpenGraphBuilder
instances.
services.AddOpenGraph();
Example:
public class MyClass
{
private readonly IOpenGraphBuilderFactory _factory;
private readonly IObjectPoolService<OpenGraphBuilder> _pool;
// use either the factory or the object pool. For demonstration purposes
// they are both included here.
public MyClass(IOpenGraphBuilderFactory factory, IObjectPoolService<OpenGraphBuilder> pool)
{
_factory = factory;
_pool = pool;
}
// with DI using the factory
public void Example1()
{
var builder = _factory.CreateBuilder();
builder.Add(new OpenGraphMetaTag("type", "example"));
builder.Add("tag2", tag2);
var openGraph = builder.Build();
}
// with DI using an object pool
public void Example2()
{
using var borrowedBuilder = _pool.Borrow();
borrowedBuilder.Instance.Add(new OpenGraphMetaTag("type", "example"));
borrowedBuilder.Instance.Add("tag2", tag2);
var openGraph = builder.Instance.Build();
}
// without DI, not recommended
public void Example3()
{
var builder = new OpenGraphBuilder();
builder.Add(new OpenGraphMetaTag("tag1", tag1));
builder.Add("tag2", tag2);
// adding a custom tag with a custom namespace
builder.Add("mycustomtag", customTag, new OpenGraphNamespace("ab", "https://example.com/ns#"));
var openGraph = builder.Build();
}
}
Asp.Net Core
Controller:
// the builder pattern
public IActionResult Example1()
{
this.SetOpenGraph(builder =>
{
builder.Add("title", title);
});
return View();
}
// the function with common tags
public IActionResult Example2()
{
this.SetOpenGraph("Home", "website", "https://example.com/image.jpg", "https://example.com/");
return View();
}
Register tag helper (usually in _ViewImports.cshtml
):
@addTagHelper *, Sidio.OpenGraph.AspNetCore
View (e.g. in _Layout.cshtml
):
<html prefix="@Html.GetOpenGraphPrefixAttributeValue()">
<head>
<open-graph />
</head>
References
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Sidio.OpenGraph (>= 2.0.0)
-
net9.0
- Sidio.OpenGraph (>= 2.0.0)
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 | |
---|---|---|---|
2.0.0 | 51 | 9/5/2025 | |
1.3.0 | 63 | 8/23/2025 | |
1.2.7 | 111 | 8/22/2025 | |
1.2.6 | 131 | 8/19/2025 | |
1.2.5 | 170 | 6/2/2025 | |
1.2.4 | 161 | 5/1/2025 | |
1.2.3 | 174 | 4/1/2025 | |
1.2.2 | 137 | 3/1/2025 | |
1.2.1 | 137 | 2/1/2025 | |
1.2.0 | 177 | 11/13/2024 | |
1.1.2 | 225 | 10/14/2024 | |
1.1.1 | 264 | 8/19/2024 | |
1.1.0 | 248 | 7/25/2024 | |
1.0.1 | 217 | 7/24/2024 | |
1.0.0 | 230 | 7/21/2024 |