c# - 在本地计算机上调试时排除执行方法

标签 c# asp.net iis azure

我正在使用以下代码来清理我的 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/

相关文章:

c# - 如何使用绑定(bind)更改数据网格文本 block 列的前景

c# - VS 代码 : How to copy files to output directory depending on build configurations

c# - Wix在安装文件夹中添加外部dll

asp.net - 如何使用 Azure DevOPs Pipeline 构建和发布 .Net 网站

asp.net-mvc - 如何将 “X-Content-Type-Options: nosniff”添加到所有响应 header

c# - 用于显示表名的复杂 sql 语句

c# - 在 aspx 网页上使用 JsonObject 的内容

asp.net - ASP.NET 控件的命运

iis - 当我在 "Configure Web Deploy Publishing Dialog"中选择用户时,为什么 IIS 管理会崩溃?

iis - 为什么 PPTX 从网站下载为 ZIP 文件?