简体   繁体   中英

MVC 4 with OWIN

Breakdown :

  • I created an empty MVC 4 project and proceeded to do the website.
  • Realizing I need authorization and authentication in my project, I looked around and found OWIN to be my solution
  • Tried to download OWIN packages through NuGet, but found that the targeting framework did not match .
  • OWIN said it needed a .NET framework of 4.5, which I'm currently at.
  • Confused, I still changed my project's .net to 4.6 , which helped me successfully download OWIN
  • Tried to run project, but gave me this error :

    "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)"

    • So I changed my project back to 4.5, grudgingly uninstalled OWIN and tried to run the project, but the error still shows.

I'm at a loss with what to do now. I can't even run my project even after bringing 4.5 back. Can I keep trying to change my .NET framework version, or at this point, should I just install a lower version of OWIN? Thanks

EDIT I have tried to reinstall newtonsoft in the package manager console through a code I found on here, which didnt work

Solved this problem by reverting my project back to .NET framework 4.5, and installing an older version of OWIN

In the package manager console:

Install-Package Microsoft.Owin.Host.SystemWeb -Version 2.1.0

then also add:

<add key="owin:AutomaticAppStartup" value="false" />

to <appSettings> in Web.config file if errors about OwinStartupAttribute show up.

Apparently the main problem I had was because I was using VS2012, which is not supported by NuGet 2.12 , the version needed for the latest OWIN.

Thanks to everyone's help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM