gpt4 book ai didi

configuration - HttpContext.Current.IsDebuggingEnabled 始终为真

转载 作者:行者123 更新时间:2023-12-04 05:55:06 26 4
gpt4 key购买 nike

为什么我的网站运行 Debug模式?

HttpContext.Current.IsDebuggingEnabled 始终为真!

捆绑不起作用!

虽然 #if DEBUG 是假的所以 DEBUG 没有定义!

在我的 appharbor 应用程序上启用了预编译。

在我的 Web.Release.config 中,我删除了调试:

<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>

Online Transformation Tester 给我的结果是用我的 Web.config 和 Web.Release.config 测试的:
<?xml version="1.0"?>
<!--
Para obtener más información sobre cómo configurar la aplicación de ASP.NET, visite
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=9831a429-a608-4055-8bb9-a2bb016f79a3.sqlserver.sequelizer.com;Initial Catalog=db9831a429a60840558bb9a2bb016f79a3;user id=wgomqcwgmezvqifh;password=JqgJKAdNmPvR6ZSwsVJYZtP7VYE2pZaTmn6Mntozm4r8TjtMAEFZRwzqHhVT4kxu;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
<add name="StorageConnectionString" connectionString="UseDevelopmentStorage=true" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="TwitterKey" value="{TwitterKey}" />
<add key="TwitterSecret" value="{TwitterSecret}" />
<add key="FacebookKey" value="{FacebookKey}" />
<add key="FacebookSecret" value="{FacebookSecret}" />
<add key="MicrosoftKey" value="{MicrosoftKey}" />
<add key="MicrosoftSecret" value="{MicrosoftSecret}" />
<add key="AnalyticsCode" value="{AnalyticsCode}" />
<add key="AnalyticsDomain" value="{AnalyticsDomain}" />
<add key="CrawlerServiceApiId" value="{CrawlerServiceApiId}" />
<add key="CrawlerServiceApplication" value="{CrawlerServiceApplication}" />
<add key="CrawlerServiceEndPoint" value="{CrawlerServiceEndPoint}" />
<add key="EmailServer" value="{EmailServer}" />
<add key="EmailUser" value="{EmailUser}" />
<add key="EmailPassword" value="{EmailPassword}" />
</appSettings>
<system.web>
<authentication mode="None" />
<compilation targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
</staticContent>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

最佳答案

从 Visual Studio 调试时,不会应用您的 web.config 转换。这意味着您的默认 Web.config 可能包含行 <compilation debug="true" targetFramework="4.6.1"/> ,强调debug="true" .

删除 debug="true"来自基本 Web.config 文件中的编译元素的属性将使 HttpContext.Current.IsDebuggingEnabled等于假。

其他一些选项:如果您尝试查看请求是否来自您的本地机器,您可以检查 Request.IsLocal而不是 HttpContext.Current.IsDebuggingEnabled ,或检查事件的调试器 Debugger.IsAttached

关于configuration - HttpContext.Current.IsDebuggingEnabled 始终为真,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22286274/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com