Unable to call Action method from UrlHelper in ASP.NET MVC 5.1

I am trying to create unit tests for my ASP.NET MVC 5.1 application.

I want to check outgoing url using UrlHelper.Action () method. I can do this with ASP.NET MVC 4, but I cannot with ASP.NET MVC 5.1.

When calling the Action () method, an exception is thrown:

An unhandled exception of type "System.NotImplementedException" occurred in System.Web.dll

Additional information: The method or operation is not implemented.

Please help me in the decision! Thanks

+4
source share
1 answer

I ran into the same problem. In my case, NotImplementedExceptioncame from HttpContextBase.GetService.

The following code solved the problem:

public override object GetService(Type serviceType)
{
    return DependencyResolver.Current.GetService(serviceType);
}
+5
source

Source: https://habr.com/ru/post/1539394/


All Articles