5

In ASP.NET MVC 4, I could ignore certain routes by using:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{*old}", new {old=@"previous(/.*)?"});
}

.NET Core doesn't have IgnoreRoute. Is there a way to achieve this in .NET Core? Maybe some custom middleware?

John-Luke Laue
  • 3,736
  • 3
  • 32
  • 60
  • 1
    If you define a middleware to handle the request before MVC, then I believe you're good to go. What are you trying to accomplish here? – gdoron Nov 07 '16 at 16:41
  • @gdoron I have two applications set up in IIS. One it .NET Core, the other is Classic ASP. If a route contains "previous/.", I want .NET Core to just flat out ignore it and the handler of the Classic ASP application will pick it up. You can do this in ISS because you can order the list of handlers. I have the .NET Core handler first and the Classic ASP handler second. I came across http://stackoverflow.com/questions/39517816/how-to-ignore-routes-in-asp-net-core-1-0-1 Is setting the Response status code to 404 the way to tell core to ignore? – John-Luke Laue Nov 07 '16 at 16:47
  • Seems like a valid way. You can always ask the developers themselves at GitHub, they are very responsive! – gdoron Nov 07 '16 at 16:55
  • I read here https://github.com/aspnet/Routing/issues/47 that if the incoming URL matches a route that is intended for MVC, but MVC can't find a matching controller/action, MVC ignores it, and the request will continue to the next middleware. – Cristi Pufu Nov 07 '16 at 17:20
  • 1
    Possible duplicate of [How to ignore routes in ASP.NET Core 1.0.1?](https://stackoverflow.com/questions/39517816/how-to-ignore-routes-in-asp-net-core-1-0-1) – Technetium Jun 13 '17 at 18:16

0 Answers0