0

I need to bind such button :

 <button type="button" onclick="location.href='@Url.Action("Compress", "Home")'" />

with such controller action :

 public void Compress()
    {
        _compressingService.CompressAllFiles();
    }

the service CompressAllFiles(); don't get the value, it is just do compressing files in server. that is why me controller method is void, but pressing this button i have:System.NullReferenceException: 'Object reference not set to an instance of an object. exception. what's wrong? may be i'm wrong bind it or my signature of controller action is not valid? thank you

Giacomo
  • 229
  • 1
  • 3
  • 11

1 Answers1

0

The exception System.NullReferenceException: 'Object reference not set to an instance of an object. is thrown because you are trying to access an object that is null. In this case, it is _compressingService which will either need instantiating or injecting

Tom Halson
  • 380
  • 3
  • 12