我如何使用這些重新寫在那些文本文件的URL。
首先,您可以根據WEBSITE_SITE_NAME從文本文件中動態檢查並替換hostURL
。以下代碼片段供您參考。
var siteName = Environment.ExpandEnvironmentVariables("%WEBSITE_SITE_NAME%");
string template = System.IO.File.ReadAllText(Server.MapPath("~/Content/email.txt"));
//determine if it is staging slot
if (siteName.IndexOf("-staging") > 0)
{
//replace hostURL based on siteName
template = Regex.Replace(template, @"hostURL:myapp.azurewebsites.net", "hostURL:myapp-staging.azurewebsites.net");
System.IO.File.WriteAllText(Server.MapPath("~/Content/email.txt"), template);
}
else
{
//replace hostURL based on siteName
template = Regex.Replace(template, @"hostURL:myapp.azurewebsites.net", "hostURL:myapp.customdomain.com");
System.IO.File.WriteAllText(Server.MapPath("~/Content/email.txt"), template);
}
其次,如果可能的話,你可以部署不同hostURL
內容生產和分期槽兩個獨立的文本文件。
可能有一個編碼解決方案,您可以檢查請求URL。你使用什麼語言/工具集? –
我們使用的是C#。 – andy