SeoEngine for filter the link?

By ICSM Computer — Published: 18-Dec-2025 • Last updated: 19-Dec-2025 60

You absolutely CAN create a small “SEO indexability engine”. And for your use case (?page=2 indexable, ?sort=hhh not indexable), this is actually the best long-term solution.

Below is a clean, production-ready SEO engine for ASP.NET MVC 5.

 

What this SEO Engine Will Do

  • Decide indexable vs non-indexable
  • Handle pagination, sort, filter, search params
  • Generate canonical URL
  • Control meta robots automatically
  • Centralized (no duplicate logic in views)

SEO RULE ENGINE (Concept)

Parameter Behavior
page indexable
sort noindex
filter noindex
search noindex

SEO Decision Model

public class SeoResult
{
    public bool IsIndexable { get; set; }
    public string CanonicalUrl { get; set; }
}

SEO Engine (Core Logic)

public static class SeoEngine
{
    private static readonly HashSet<string> NonIndexableParams =
        new HashSet<string>(StringComparer.OrdinalIgnoreCase)
        {
            "sort",
            "filter",
            "search",
            "utm_source",
            "utm_medium"
        };

    public static SeoResult Evaluate(HttpRequestBase request)
    {
        var query = request.QueryString;
        bool hasNonIndexableParam = false;
        
        foreach (string key in query.Keys)
        {
            if (key == null) continue;

            if (NonIndexableParams.Contains(key))
                hasNonIndexableParam = true;
        }

        var baseUrl = request.Url.GetLeftPart(UriPartial.Path);
 
        return new SeoResult
        {
            IsIndexable = !hasNonIndexableParam,
            CanonicalUrl = baseUrl 
        };
    }
}

  • Works in ASP.NET MVC 5
  • Clean extension syntax
  • No breaking changes

Extension Method for HtmlHelper

public static class SeoEngineExtensions
{
    public static SeoResult Evaluate(this HtmlHelper htmlHelper)
    {
        var request = htmlHelper.ViewContext.HttpContext.Request;
        return SeoEngine.Evaluate(request);
    }
}

Use Engine in Controller

public ActionResult Index(int page = 1, string sort = null)
{
    var seo = SeoEngine.Evaluate(Request);

    ViewBag.CanonicalUrl = seo.CanonicalUrl;
    ViewBag.NoIndex = !seo.IsIndexable;

    ViewBag.Page = page;

    return View();
}

Layout (_Layout.cshtml)

<link rel="canonical" href="@ViewBag.CanonicalUrl" />

@if (ViewBag.NoIndex == true)
{
    <meta name="robots" content="noindex, follow" />
}
else
{
    <meta name="robots" content="index, follow" />
}

What This Engine Achieves

URL Canonical Indexable
/articles /articles indexable
/articles?page=2 /articles?page=2 indexable
/articles?sort=asc /articles noindexable
/articles?sort=asc&page=2 /articles?page=2 noindexable
/articles?utm_source=fb /articles noindexable
  • Google-safe
  • No duplicate content
  • Crawl budget preserved

Why This Is the RIGHT Approach

  • Centralized SEO logic
  • Easy to extend
  • No fragile Razor conditions
  • Works with pagination, filters, tracking params
  • Matches Google best practices

 

Also Read

  1. How to implement WebSocket in .net for chats?
  2. Now Essential Why E-E-A-T Optimization Is for Top Google Rankings
  3. How to Implement ChatGPT in a Website (Complete Guide)
ICSM Computer
ICSM Computer
IT-Hardware & Networking

Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.