1
Vote

NullReferenceException with invalid routes

description

Naivgator.Navigate(string) does not check whether the route result is a success or not, which causes a NullReferenceException in case no route was found:
 
    public void Navigate(string requestUri)
    {
        var path = requestUri;
        var route = _routes.MatchPathToRoute(path);  //result may be false, in this case, the "Route" property is null
        var handler = route.Route.CreateRouteHandler(); //Route property accessed
    }

comments

stovellp wrote Jun 3, 2010 at 1:24 PM

Hi Philipp, thanks for the report. I've fixed this and added a few unit tests for that area.

When navigating to a route that cannot be resolved, you should now receive an error such as:

The request values 'controller=Wizard; baz=Welcome' could not be routed.
  • Route with specification 'patient/{action}' did not match: A value for the parameter 'action' was not provided.
  • Route with specification 'search/{action}' did not match: A value for the parameter 'action' was not provided.
You'll need to build latest from source code (the build server is offline).

Paul

wrote Jun 3, 2010 at 1:26 PM

stovellp wrote Jun 3, 2010 at 1:26 PM

This has been fixed in the latest source code.



** Closed by stovellp 6/3/2010 5:26 AM

stovellp wrote Jun 3, 2010 at 1:26 PM

This has been fixed in the latest source code.

wrote Feb 13, 2013 at 12:27 AM