locked
error while working with web api RRS feed

  • Question

  • User81789783 posted

    i have below error while working with web api

    Detailed Error Information:

    Module    IIS Web Core
    Notification    Unknown
    Handler    Not yet determined
    Error Code    0x80070032
    Config Error    The configuration section 'entityFramework' cannot be read because it is missing a section declaration
    Config File    \\?\c:\users\erum\documents\visual studio 2015\Projects\StudentAPI\StudentAPI\web.config
    Requested URL    http://localhost:29027/
    Physical Path    
    Logon Method    Not yet determined
    Logon User    Not yet determined

    Request Tracing Directory

    Sunday, November 22, 2020 9:56 AM

Answers

  • User1686398519 posted

    Hi erum, 

    According to the link you provided, you are not using Entity Framework. You may need to delete the following code in your web.config file:

      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>

    Best Regards,

    YihuiSun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 23, 2020 7:34 AM

All replies

  • User81789783 posted

    here is my code snippt

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net.Http;
    using System.Web.Http;
    using Microsoft.Owin.Security.OAuth;
    using Newtonsoft.Json.Serialization;

    namespace StudentAPI
    {
        public static class WebApiConfig
        {
            public static void Register(HttpConfiguration config)
            {
                // Web API configuration and services
                // Configure Web API to use only bearer token authentication.
                config.SuppressDefaultHostAuthentication();
                config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

                // Web API routes
                config.MapHttpAttributeRoutes();

                config.Routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }


                );
                config.Formatters.Remove(config.Formatters.XmlFormatter);  //Remove default XML formatter

                //Add JSON Formatter

                config.Formatters.JsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;

                //Add CamelCase Property

                config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();


                    }
        }
    }

    Sunday, November 22, 2020 9:57 AM
  • User81789783 posted
    <!--?xml version="1.0" encoding="utf-8"?-->
    <?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>
     
      
      
      
      
      <connectionStrings>
        <add name="Student_dbConnectionString" connectionString="Data Source=erum-pc;Initial Catalog=Student_db;Integrated Security=True"
          providerName="System.Data.SqlClient" />
      </connectionStrings>
      <appSettings></appSettings>
      <system.web>
        <authentication mode="None" />
        <compilation debug="true" targetFramework="4.5.1" />
        <httpRuntime targetFramework="4.5.1" />
      </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="1.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.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>
        </assemblyBinding>
      </runtime>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
        <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>



    <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=301879 -->

    <configuration> <connectionstrings> <add name="Student_dbConnectionString" connectionstring="Data Source=erum-pc;Initial Catalog=Student_db;Integrated Security=True" providername="System.Data.SqlClient"></add> </connectionstrings> <appsettings></appsettings> <system.web> <authentication mode="None"></authentication> <compilation debug="true" targetframework="4.5.1"></compilation> <httpruntime targetframework="4.5.1"></httpruntime> </system.web> <system.webserver> <modules> <remove name="FormsAuthentication"></remove> </modules> <handlers> <remove name="ExtensionlessUrlHandler-Integrated-4.0"></remove> <remove name="OPTIONSVerbHandler"></remove> <remove name="TRACEVerbHandler"></remove> <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" precondition="integratedMode,runtimeVersionv4.0"></add> </handlers> </system.webserver> <runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentassembly> <assemblyidentity name="Microsoft.Owin.Security" publickeytoken="31bf3856ad364e35"></assemblyidentity> <bindingredirect oldversion="1.0.0.0-3.0.1.0" newversion="3.0.1.0"></bindingredirect> </dependentassembly> <dependentassembly> <assemblyidentity name="Microsoft.Owin.Security.OAuth" publickeytoken="31bf3856ad364e35"></assemblyidentity> <bindingredirect oldversion="1.0.0.0-3.0.1.0" newversion="3.0.1.0"></bindingredirect> </dependentassembly> <dependentassembly> <assemblyidentity name="Microsoft.Owin.Security.Cookies" publickeytoken="31bf3856ad364e35"></assemblyidentity> <bindingredirect oldversion="1.0.0.0-3.0.1.0" newversion="3.0.1.0"></bindingredirect> </dependentassembly> <dependentassembly> <assemblyidentity name="Microsoft.Owin" publickeytoken="31bf3856ad364e35"></assemblyidentity> <bindingredirect oldversion="1.0.0.0-3.0.1.0" newversion="3.0.1.0"></bindingredirect> </dependentassembly> <dependentassembly> <assemblyidentity name="Newtonsoft.Json" culture="neutral" publickeytoken="30ad4fe6b2a6aeed"></assemblyidentity> <bindingredirect oldversion="0.0.0.0-6.0.0.0" newversion="6.0.0.0"></bindingredirect> </dependentassembly> <dependentassembly> <assemblyidentity name="System.Web.Optimization" publickeytoken="31bf3856ad364e35"></assemblyidentity> <bindingredirect oldversion="1.0.0.0-1.1.0.0" newversion="1.1.0.0"></bindingredirect> </dependentassembly> <dependentassembly> <assemblyidentity name="WebGrease" publickeytoken="31bf3856ad364e35"></assemblyidentity> <bindingredirect oldversion="0.0.0.0-1.5.2.14234" newversion="1.5.2.14234"></bindingredirect> </dependentassembly> <dependentassembly> <assemblyidentity name="System.Web.Helpers" publickeytoken="31bf3856ad364e35"></assemblyidentity> <bindingredirect oldversion="1.0.0.0-3.0.0.0" newversion="3.0.0.0"></bindingredirect> </dependentassembly> <dependentassembly> <assemblyidentity name="System.Web.Mvc" publickeytoken="31bf3856ad364e35"></assemblyidentity> <bindingredirect oldversion="1.0.0.0-5.2.3.0" newversion="5.2.3.0"></bindingredirect> </dependentassembly> <dependentassembly> <assemblyidentity name="System.Web.WebPages" publickeytoken="31bf3856ad364e35"></assemblyidentity> <bindingredirect oldversion="1.0.0.0-3.0.0.0" newversion="3.0.0.0"></bindingredirect> </dependentassembly> </assemblybinding> </runtime> <entityframework> <defaultconnectionfactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"></defaultconnectionfactory> <providers> <provider invariantname="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"></provider> </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=\"Web\" /optionInfer+"> </compiler></compiler></compilers> </system.codedom> </configuration>

    Sunday, November 22, 2020 9:57 AM
  • User-474980206 posted

    The error is pretty clear. You did not register a support module for entityFramework section. See the <configSections> documentation. You probably need something like

    	<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, Culture=neutral" requirePermission="false" />
    	</configSections>
    	

    Sunday, November 22, 2020 5:12 PM
  • User1686398519 posted

    Hi erum, 

    When you install the EntityFramework NuGet package, the entityFramework section will be automatically added to the project configuration file.

    If the entityFramework section is not configured in the web.config file, you need to add it manually.

    You can check this link to learn about the entityFramework section.

    Best Regards,

    YihuiSun

    Monday, November 23, 2020 1:47 AM
  • User81789783 posted

    i m following this link by the way

    https://www.commonlounge.com/community/8733d50717d04254982be176ac58dd9f

    where i did not find Entity link to work with other than web api

    Monday, November 23, 2020 6:49 AM
  • User1686398519 posted

    Hi erum, 

    According to the link you provided, you are not using Entity Framework. You may need to delete the following code in your web.config file:

      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>

    Best Regards,

    YihuiSun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 23, 2020 7:34 AM