我正在使用以下代码来清理我的 Azure 应用程序的数据库。
protected void Application_End(object sender, EventArgs e)
{
core.cleanUpDB();
}
我可以在调试时阻止在本地计算机上执行此操作吗?我只想仅在已部署的 Azure 应用程序上执行此操作。
提前致谢。
最佳答案
您可以使用HttpRequest.IsLocal区分本地请求和服务器请求。
protected void Application_End(object sender, EventArgs e)
{
if(!System.Web.HttpContext.Current.Request.IsLocal)
core.cleanUpDB();
}
关于c# - 在本地计算机上调试时排除执行方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13356606/