0

After I installed and referenced the JSNLog package into my MVC project, I'm experiencing an error when ever I click a link.

For example,

<a href="@Url.Action("Bar", "Foo")">Link</a>

usually produce

<a href="/Foo/Bar">Link</a>

but after I start using the JSNLog, it now produce

<a href="/jsnlog.logger?action=Bar&controller=Foo">Link</a>

which will direct to a link

http://localhost:51745/jsnlog.logger?action=Bar&controller=Foo

which shows

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

I believe JSNLog is trying to send back a exception or log event back to the server whenever it has a chance to access the server.
Am I missing something to make this functional?

Warren Rumak
  • 3,824
  • 22
  • 30

2 Answers2

4

This bug existed when the original post was created, but it has been fixed a few version ago now (I am the author of JSNLog).

user1147862
  • 4,096
  • 8
  • 36
  • 53
  • I use Angular 2 and Web API. My client's address(http://localhost:4200) is separate from the server's address(http://localhost:23900), but it uses the local address when posting content. How can I change It? POST http://localhost:4200/jsnlog.logger 404 (Not Found) – BehrouzMoslem Sep 26 '17 at 11:34
  • Hi Matt, I am facing issue while implementing JSNLog in MVC app for .NET 4.5, can you please help me here. Ref: https://stackoverflow.com/questions/51982482/unable-to-implement-jsnlog-on-net-4-5-mvc-application – Indranil Aug 27 '18 at 11:07
3

This is actually caused by the Ignore route they inject in App_Start, moving it into your routes collection manually fixes the issue. It happens because you don't manually define routes for the rest of the controllers, so .net tries to resolve to the first one it finds defined.

In App_Start\JSNLogConfig.cs take out

RouteTable.Routes.Insert(0, new Route("jsnlog.logger/{*pathInfo}", new StopRoutingHandler()));

In RouteConfig.cs add

routes.IgnoreRoute("jsnlog.logger/{*pathInfo}");

And all your other routes should start working fine.

Alexandru Puiu
  • 741
  • 6
  • 16