Giter Site home page Giter Site logo

net-trailingslash's Introduction

TrailingSlash

Redirects the request to the same URL with a trailing slash for a given set of cases.

I'm not here to argue "to slash or not slash" (1 2 3), but if you choose to do so, this is what I use for ASP.NET (MVC) web sites.

Usage

using TrailingSlashLibrary;

var slash = new TrailingSlash();

You can configure some set of exceptions (urls to leave alone). There are flags for empty urls (ExceptEmpty), with extension (ExceptWithExtension) and from API (ExceptFromApi). All set to True by default.

You can also add exceptions of your own in the Except property, such as:

slash.Except =
    url =>
    {
        return url.Contains("mini-profiler-resources");
    };

(here we are ignoring MiniProfiler calls)

Now it's just a matter to put an Append call in you Application_BeginRequest:

protected void Application_BeginRequest(object sender, EventArgs e)
{
    slash.Append();
}

Done.

net-trailingslash's People

Contributors

tallesl avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.