0

.Net 4.6.1 framework
I've Upgraded NewtonSoft in all my projects from 9.0.1 to 12.0.3.

Before the upgrade everything works fine - Now I got in my home page:

HTTP Error 404.0 - Not Found
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL https://www.example.com:443/home/index
Physical Path C:\path\to\home\index
Logon Method Anonymous
Logon User Anonymous

What could be the issue?

enter image description here

4
  • I don't see any way it can possibly cause a 404 result because it's a later step in the pipeline. Indeed, the handler is the "static file" handler, rather than a controller. Jul 16, 2020 at 6:23
  • Thanks @John for responding - could you a bit explain that? or direct me to relevant resources? once I downgrade back to newtonSoft 9 all starts to work again.
    – chenop
    Jul 16, 2020 at 6:25
  • It looks like it's a problem with routing, because it's hitting the static file handler (i.e. it's expecting that /home/index is a physical file). Without seeing your configuration, etc. it's difficult to provide more advice. Jul 16, 2020 at 6:26
  • 1
    Handler StaticFile isn't what I would expect.
    – mjwills
    Jul 16, 2020 at 7:03

1 Answer 1

1

Ok, After I debug the global.asax I found there was an exception been thrown.

System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' ---> System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

So I understand my web.config still looks for NewtonSoft 9.

Changing in the web.config from this:

<dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>

to this:

<dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>

Solved the issue for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.