我需要临时禁用捆绑和压缩,以便于调试 JavaScript 和 CSS 问题。我希望在运行时通过向 QueryString 添加参数来实现这一点。
http://domain.com/page?DisableOptimizations=true
这是我正在考虑的方法。
protected void Application_BeginRequest(object sender, EventArgs e)
{
// Enable for every request
BundleTable.EnableOptimizations = true;
// Disable for requests that explicitly request it
bool disable;
bool.TryParse(Context.Request.QueryString["DisableOptimizations"], out disable);
if (disable)
{
BundleTable.EnableOptimizations = false;
}
}
- 我在每个web请求上设置这个静态属性是否存在潜在问题?(Web应用程序将在Web农场上运行)
- 有更好的处理方法吗?