← Country website blocking
SERVER-SIDE COUNTRY RULES · .NET

Apply country rules in .NET.

Look up the request country, apply your policy and decide before sending protected content.

1. Install and configure

Add the extracted Origooo.csproj as a project reference in your .NET 8 ASP.NET Core application. Register OrigoooClient and CountryPolicy, then place CountryMiddleware before protected endpoints. Validate compilation and integration in your application.

Download .NET SDK

Set ORIGOOO_API_KEY on your server. Use a secret key with lookup scope and the API origin https://orig.ooo. These SDKs are source downloads, not public package-registry releases.

2. Apply the rule before your response

This example blocks US and GB, allows other matched countries, and denies when location is unknown. Choose the unknown behaviour for your own service before deployment.

using Origooo;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton(new OrigoooClient(new HttpClient(),
    Environment.GetEnvironmentVariable("ORIGOOO_API_KEY")!,
    new Uri("https://orig.ooo")));
builder.Services.AddSingleton(new CountryPolicy(
    blocked: new[] { "US", "GB" }, unknown: "deny"));
var app = builder.Build();
// If needed, configure Forwarded Headers with explicit trusted proxies
// before this middleware. Never trust arbitrary forwarded headers.
app.UseMiddleware<CountryMiddleware>();
app.MapGet("/protected", () => "Allowed content");
app.Run();

.NET setup and framework guide →

3. Verify your request path

  1. Verify an allowed country reaches your application handler.
  2. Verify a blocked country returns 403 before protected content is rendered.
  3. Simulate a timeout, 429, missing country and invalid IP; verify your explicit unknown policy.
  4. Confirm untrusted forwarded headers cannot change the visitor IP.
  5. Keep administrator/health-route exceptions in trusted application code.

Choose when to use this

Use server policies for regional service availability and applications with a defined country policy. For an offer or message that merely appears or disappears, use the browser decision element. Browser hiding does not prevent downloading content already sent to the client.

The API supplies approximate geography. VPNs, mobile networks and proxies affect the result. Treat a country rule as one input to your application, not proof of residence.

Complete .NET reference → · Error handling · Request speed and credits

YOUR NEXT BUILD STARTS HERE

Get your free API key.

1,000 monthly credits. No credit card required.

Account services are not connected in this preview. Explore the dashboard or download the implementation from your workspace.
Read the integration guide

Production accounts require verified email. Google OAuth and Paddle need deployment credentials.