为.net core 3.1 web api应用程序添加app.config。

问题描述 投票:0回答:1

我正在把我的项目从.net框架转移到.net core 3.1 web api上。.net似乎不包括app.config文件,我需要添加它。我添加了一个,但它的不识别。有什么方法可以将app.config文件添加到.Net core应用中吗?或者有什么可以替代app.config .net core的方法吗?

App.config:

<configSections>
        <section name="corememorycache" type="NHibernate.Caches.CoreMemoryCache.CoreMemoryCacheSectionHandler,NHibernate.Caches.CoreMemoryCache" />
        <section name="hibernate-configuration"
                 type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
    </configSections>

    <corememorycache expiration-scan-frequency="00:05:00">
        <cache region="foo" expiration="500" sliding="true" />
        <cache region="noExplicitExpiration" sliding="true" />
    </corememorycache>
asp.net-core asp.net-core-webapi app-config asp.net-core-3.1
1个回答
0
投票

在.NET Core中,方法有点不同。默认情况下,你应该使用 appsettings.json档案

下面是一篇关于.NET Core配置的文章。https:/docs.microsoft.comen-usaspnetcorefundamentalsconfiguration?view=aspnetcore-3.1。

© www.soinside.com 2019 - 2024. All rights reserved.