Problems running/publishing WEP API on IIS10!

Asked

Viewed 420 times

1

I want to publish my ASP.NET Web API via filesystem, but I’m having an Assembly error while running the site on IIS10.

For the VS I can spin, but for the IIS I can’t.

NOTE: I already have the DLL in bin folder.

Error:

Could not load file or Assembly 'Microsoft.CodeDom.Providers.Dotnetcompilerplatform...

  • Which version of . net is sending your webApi compiled?

1 answer

1


Who uses Roslyn for publication

If your project has references Roslyn and you are interested in posting it on a iss server, you will probably get unwanted errors on your website since many providers of hosting have not updated their servers and consequently do not support Roslyn.

To solve this problem, you will have to remove the Roslyn compiler from the project. Removing Roslyn should not affect the functionality of your code. It worked smoothly for me and other projects (C# 4.5.2) I worked on.

Take the following steps:

  1. Remove the following Nuget packages using the command line provided below (or you can use the Nuget Package Manager by right-clicking the Solution Root of your Project and removing them).

    PM> Uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
    PM> Uninstall-package Microsoft.Net.Compilers
    
  2. Remove the following code from the Web.Config file. Use this method only if step 1 does not solve your problem.

    <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
    

Restart your IIS and your problem must be solved.

Translated and adapted from IIS Publishing problems.

  • It’s already added, but the problem is in IIS. I’ve also already Updated the Nuget package :/

  • Can you run local on IIS? Or is your problem just when publishing it?

  • I can run local through VS but the problem is when to publish.

  • Are you using Roslyn to publish your application? Is there a Roslyn folder in your project?

  • Yes there is the Roslyn folder.

  • If I do this he error too, the following error : The view 'Index' or its master was not found or no view engine Supports the searched Locations. The following Locations Were searched: ~/Views/Home/Index.aspx ~/Views/Home/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.xasc ~/Views/Home/Index.cshtml ~/Views/Home/Index.vbhtml ~/Views/Shared/Index.cshtml ~/Views/Shared/Index/Index.vbhtml

  • This is your application’s Path problem. Just like the error tells, it did not find the view Index. But this should not happen, since it is a Web API and the same should not have pages (Views).

  • Yes I did not touch anything in the project I created a new one and this giving the same error.

  • The only View your API should have is Home, which will then call the API itself. When creating the API you checked the Web Forms option, by chance? I just created an API here and it worked perfectly (I didn’t check the Web Forms option).

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.