Skip to content

Instantly share code, notes, and snippets.

@JohnTube
JohnTube / Global.asax.cs
Last active April 3, 2019 13:49 — forked from AniAko/gist:3f955b5ad9a71f17635e
ASP.Net MVC: Do Not Allow URL to end in trailing slash without URL rewrite and without going to controller
// Put this in Global.asax.cs
// Do Not Allow URL to end in trailing slash
protected void Application_BeginRequest(object sender, EventArgs e)
{
string url = HttpContext.Current.Request.Url.AbsolutePath;
if (string.IsNullOrEmpty(url))
{
return;
}