locked
Deploy Web Api RRS feed

  • Question

  • User1979860870 posted

    Hi

      How to deploy MVC Web Api . I have published in c:\PM. Then i followed below link but i am getting error

    https://www.c-sharpcorner.com/UploadFile/3d39b4/publish-and-host-Asp-Net-web-api/

    HTTP Error 500.19 - Internal Server Error
    The requested page cannot be accessed because the related configuration data for the page is invalid.
    
    Detailed Error Information:
    Module	   IIS Web Core
    Notification	   BeginRequest
    Handler	   Not yet determined
    Error Code	   0x80070021
    Config Error	   This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
    Config File	   \\?\C:\PM\web.config
    Requested URL	   http://localhost:8080/api/employees
    Physical Path	   C:\PM\api\employees
    Logon Method	   Not yet determined
    Logon User	   Not yet determined
    
    Config Source:
       24:     </modules>
       25:     <handlers>
       26:       <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=301879
      -->
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <connectionStrings>
        <add name="DefaultConnection" connectionString="metadata=res://*/PMDataModel.csdl|res://*/PMDataModel.ssdl|res://*/PMDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=Server\NA;initial catalog=EInvoicing;persist security info=True;user id=sa;password=sa@;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
        <add name="PMDbEntities" connectionString="metadata=res://*/PMDataModel.csdl|res://*/PMDataModel.ssdl|res://*/PMDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=Server\NAO;initial catalog=EInvoicing;persist security info=True;user id=sa;password=sa@;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
      </connectionStrings>
      <appSettings></appSettings>
      <system.web>
        <authentication mode="None" />
        <compilation debug="true" targetFramework="4.5.2" />
        <httpRuntime targetFramework="4.5.2" />
      </system.web>
      <system.webServer>
        <modules>
          <remove name="FormsAuthentication" />
        </modules>
        
      <handlers>
          <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
          <remove name="OPTIONSVerbHandler" />
          <remove name="TRACEVerbHandler" />
          <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers></system.webServer>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
            <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="mssqllocaldb" />
          </parameters>
        </defaultConnectionFactory>
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>
      <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>
      </system.codedom>
    </configuration>

    Thanks

    Monday, February 22, 2021 5:16 AM

All replies

  • User-474980206 posted

    The error is pretty clear. In your web.config you are trying to remove a handler, but the iis configuration is such that this is not allowed. You will need to remove the <handlers> section or have the iis configuration changed to allow removing handlers.

    Monday, February 22, 2021 4:08 PM
  • User1312693872 posted

    Hi,jagjit saini

    This problem can occur if the specified portion of the IIS configuration file is locked at a higher configuration level, check the official site:

    result-code-0x80070021

    And about the solution, I found some links, they have the same problem and solved, you can check them:

    http-error-500-19-and-error-code-0x80070021

    how-to-solve-http-error-500-19-internal-server-error-remove-name-extensio

    And check that you have ASP.NET role installed along with IIS :

    iis-8-asp-net-mvc-http-error-500-19

    Best Regards,

    Jerry Cai

    Tuesday, February 23, 2021 1:57 AM
  • User1979860870 posted

    Hi

       When i give localhost:8080 it shows like below

    localhost - /
     2/22/2021 10:59 AM        <dir> Areas
     2/22/2021 10:59 AM        <dir> bin
     2/22/2021 10:59 AM        <dir> Content
     2/15/2021 12:37 PM        32038 favicon.ico
     2/22/2021 10:59 AM        <dir> fonts
     2/15/2021 12:37 PM          112 Global.asax
     2/19/2021  9:50 AM         3375 packages.config
     2/22/2021 10:59 AM        <dir> Scripts
     2/22/2021 10:59 AM        <dir> Views
     2/23/2021  9:35 AM         6373 Web.config

    When i gives then below error comes

    HTTP Error 404.0 - Not Found
    The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
    
    Most likely causes:
    The directory or file specified does not exist on the Web server.
    The URL contains a typographical error.
    A custom filter or module, such as URLScan, restricts access to the file.
    
    Things you can try:
    Create the content on the Web server.
    Review the browser URL.
    Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click here.
    
    Detailed Error Information:
    Module	   IIS Web Core
    Notification	   MapRequestHandler
    Handler	   StaticFile
    Error Code	   0x80070002
    Requested URL	   http://localhost:8080/api/employees
    Physical Path	   C:\PM\api\employees
    Logon Method	   Anonymous
    Logon User	   Anonymous

    When i run directly thru Visual Studio with Url - http://localhost:40991/api/Employees it works.

    ON IIS Server i have given Port 8080 bit it does not work.

    Thanks

    Tuesday, February 23, 2021 4:10 AM
  • User-474980206 posted

    IIS has not been configured to host your webapi. It’s is treating it as static content, with directory browse enabled. 

    Tuesday, February 23, 2021 3:50 PM
  • User1979860870 posted

    Hi Bruce

      wht other steps i need to do. I have enabled Directory browsing

    Thanks

    Wednesday, February 24, 2021 3:43 AM
  • User1312693872 posted

    Hi,jagjit saini

    Try to add the following code to the web.config file:

    <system.webServer>
      <modules runAllManagedModulesForAllRequests="true" >
       <remove name="UrlRoutingModule"/>    
      </modules>
    </system.webServer>
    

    Best Regards,

    Jerry Cai

    Thursday, February 25, 2021 7:27 AM
  • User-474980206 posted

    In iis create an application. You will need to set an app pool and a virtual path. Depending on your requirements you may need to set an identity to run the app.

    Thursday, February 25, 2021 4:05 PM