2

I got a main website(Net 4.5.2) in my IIS. Then I create separate webapi(Net 4.7.2) and run it as virtual application inside the main website. But, when I test the webapi to GET a data, it will give me an error about missing assembly reference. Below is the error.

Parser Error Message: Could not load file or assembly 'System.Web.Optimization' or one of its dependencies. The system cannot find the file specified.

Then I install this missing assembly to the webapi and then its working perfectly.

So, the problem is:

  1. Why do I need to install this assembly even my webapi doesn't used this assembly?
  2. Is it related with the web api run as virtual application inside my main website? or because of different version?
  3. How do I skip this without need to install unused assembly to the webapi?
Erik Philips
  • 53,428
  • 11
  • 128
  • 150
saf21
  • 814
  • 1
  • 15
  • 32
  • One of your projects in that solution must reference it? If it's not an obvious reference do a text search of all the .csproj files in the solution. – sellotape Dec 07 '18 at 10:31
  • Sorry, I'm quite new in Asp.Net, not fully understand. Can you give any advice how to do this? – saf21 Dec 07 '18 at 11:06
  • Did you edit the question? It doesn't show it but I thought I saw a different assembly mentioned when I first commented? Either way [this](https://stackoverflow.com/questions/27510590/could-not-load-file-or-assembly-system-web-optimization-version-1-0-0-0-cultu) might help. – sellotape Dec 07 '18 at 11:25

1 Answers1

2

I found an answer for this. It because of inheritance to the nested application in the IIS. Need to set inheritance to child application false in the main site web.config. Here is the solution link to this issue.

<location path="." inheritInChildApplications="false">
  <system.web>
    <!-- ... -->
  </system.web>
</location>
saf21
  • 814
  • 1
  • 15
  • 32