我如何使用这些重新写在那些文本文件的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