将来,我们将使用 Windows Azure 网站来满足我们的基本托管需求。由于云与本地有非常具体的配置设置,您如何管理这些设置?举个例子:
本地开发服务器:
string path = AppSettings["StoragePath"];
<add key="StoragePath" value="c:\temp" />
视窗天青:
string path = AppSettings["StoragePath"];
<add key="StoragePath" value="xyz" />
您是否在每次发布之前手动更改配置文件中的 StoragePath,或者代码中是否有可以执行的操作,例如:
<add key="LocalStoragePath" value="c:\temp" />
<add key="BlobStoragePath" value="xyz" />
string path;
if (Azure)
{
path = AppSettings["BlobStoragePath"];
}
else
{
path = AppSettings["LocalStoragePath"];
}
如果后者是可能的,我如何确定环境是否是 Windows Azure?