是否可以为web的特定部分提供单独的配置文件.配置?具体来说,我想把iis7的重写部分移出网络.配置并保存到它自己的配置文件中.

推荐答案

您当然可以将重写规则和映射移出到一个单独的文件:

Storing URL rewrite mappings in a separate file

<system.webServer>
  <rewrite>
    <rewriteMaps configSource="rewritemaps.config" />
    <rules configSource="rewriteRules.config" />
  </rewrite>
</system.webServer>

此外,您还可以将许多配置部分移动到它们自己的文件中:

<appSettings configSource="appSettings.config" /> [Docs]

<connectionStrings configSource="connectionStrings.config"/> [Docs]

<pages configSource="pages.config"/> [Docs]

有关更多信息,请参阅本页,该页将帮助您决定是否可以在外部存储配置部分:

General Attributes Inherited by Section Elements

Asp.net相关问答推荐

ASP .Net Web API 将图像下载为二进制

ASP.NET @Register 与 @Reference

Dotnet core 2.0 身份验证多模式身份 cookie 和 jwt

登录成功后 User.Identity.IsAuthenticated 为 false

将 null 转换为字符串的函数

使用 jQuery.ajax() 时如何处理错误?

如何在页面的基类中执行 Page_Load()?

在asp.net mvc c#中使用cookie

返回值使用 String result=Command.ExecuteScalar() 结果返回 null 时发生错误

如何在 ASP.NET Web API 中使用非线程安全的 async/await API 和模式?

stream.CopyTo - 文件为空.网

无法使用单例Microsoft.AspNetCore.Hosting.Internal.HostedServiceExecutor中的范围服务MyDbContext

为什么aspx文件会返回404(找不到页面)

如何针对异常需求自定义 ASP.NET Web API AuthorizeAttribute

无法共同创建探查器错误 - 但未使用探查器

实体框架:如何解决外键约束可能导致循环或多个级联路径?

单独装配和路由中的控制器

System.Threading.Tasks - 限制并发任务的数量

ASP.net 网站中的 C# 密码文本框

在.net的内存数据库中