ivaylokenov / AspNet.Mvc.TypedRouting

A collection of extension methods providing strongly typed routing and link generation for ASP.NET Core MVC projects.
https://mytestedasp.net/
MIT License
485 stars 36 forks source link

NullReferenceException: Object reference not set to an instance of an object. #14

Closed skorunka closed 8 years ago

skorunka commented 8 years ago

_Layout.cshtml:

@(this.Url.Action<TestController>(x => x.Index()))

results in:

image

ivaylokenov commented 8 years ago

@skorunka Was this working before? Can you provide me the controller code and your Startup class?

This can happen in two scenarios:

  1. The type is not a valid controller
  2. .UseTypedRouting() is not called in the startup

I believe I need to put a friendlier exception.

skorunka commented 8 years ago

@ivaylokenov You are right. i forgot to use extension "UseTypedRouting" in Startup. Better exception or text would be nice. Thank you.

ivaylokenov commented 8 years ago

I will keep this open in order to implement a friendlier exception message when people forget to call that method.