Fórum Web.Config - Exibição de erros #468272
29/01/2014
0
Estou finalizando uma aplicação webform em c#, e preciso que neste momento - desenvolvimento - todos os erros sejam exibidos no browser. Na sequência farei os tratamentos usando try - Catch.
No web.config a opção CustomErrors já está como Off. Só que os erros não aparecem. Por exemplo, coloquei um trecho insert em uma página visando o erro e simplesmente a página foi carregada. Diante desta situação instalei o ELMAH para tentar visualizar o que acontecia, mas também infelizmente nada é exibido porque o erro não acontece.
O que mais eu poderia fazer neste caso?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | <? xml version = "1.0" ?> <!-- For more information on how to configure your ASP.NET application, please visit --> < configuration > < configSections > <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> < section name = "entityFramework" type = "System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission = "false" /> < sectionGroup name = "dotNetOpenAuth" type = "DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth.Core" > < section name = "messaging" type = "DotNetOpenAuth.Configuration.MessagingElement, DotNetOpenAuth.Core" requirePermission = "false" allowLocation = "true" /> < section name = "reporting" type = "DotNetOpenAuth.Configuration.ReportingElement, DotNetOpenAuth.Core" requirePermission = "false" allowLocation = "true" /> < section name = "openid" type = "DotNetOpenAuth.Configuration.OpenIdElement, DotNetOpenAuth.OpenId" requirePermission = "false" allowLocation = "true" /> < section name = "oauth" type = "DotNetOpenAuth.Configuration.OAuthElement, DotNetOpenAuth.OAuth" requirePermission = "false" allowLocation = "true" /> </ sectionGroup > <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> < sectionGroup name = "elmah" > < section name = "security" requirePermission = "false" type = "Elmah.SecuritySectionHandler, Elmah" /> < section name = "errorLog" requirePermission = "false" type = "Elmah.ErrorLogSectionHandler, Elmah" /> < section name = "errorMail" requirePermission = "false" type = "Elmah.ErrorMailSectionHandler, Elmah" /> < section name = "errorFilter" requirePermission = "false" type = "Elmah.ErrorFilterSectionHandler, Elmah" /> </ sectionGroup > </ configSections > < connectionStrings /> < system.web > < globalization culture = "pt-BR" uiCulture = "pt-BR" /> < customErrors mode = "Off" /> < compilation debug = "true" targetFramework = "4.0" /> < authentication mode = "Forms" > < forms name = "Default" loginUrl = "~/Access/Login.aspx" protection = "All" path = "/" /> </ authentication > < profile defaultProvider = "DefaultProfileProvider" > < providers > < add name = "DefaultProfileProvider" type = "System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName = "DefaultConnection" applicationName = "/" /> </ providers > </ profile > < membership defaultProvider = "DefaultMembershipProvider" > < providers > < add name = "DefaultMembershipProvider" type = "System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName = "DefaultConnection" enablePasswordRetrieval = "false" enablePasswordReset = "true" requiresQuestionAndAnswer = "false" requiresUniqueEmail = "false" maxInvalidPasswordAttempts = "5" minRequiredPasswordLength = "6" minRequiredNonalphanumericCharacters = "0" passwordAttemptWindow = "10" applicationName = "/" /> </ providers > </ membership > < roleManager defaultProvider = "DefaultRoleProvider" > < providers > < add name = "DefaultRoleProvider" type = "System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName = "DefaultConnection" applicationName = "/" /> </ providers > </ roleManager > <!-- If you are deploying to a cloud environment that has multiple web server instances, you should change session state mode from "InProc" to "Custom". In addition, change the connection string named "DefaultConnection" to connect to an instance of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express. --> < sessionState mode = "InProc" customProvider = "DefaultSessionProvider" > < providers > < add name = "DefaultSessionProvider" type = "System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName = "DefaultConnection" /> </ providers > </ sessionState > < pages controlRenderingCompatibilityVersion = "3.5" clientIDMode = "AutoID" /> < httpModules > < add name = "ErrorLog" type = "Elmah.ErrorLogModule, Elmah" /> < add name = "ErrorMail" type = "Elmah.ErrorMailModule, Elmah" /> < add name = "ErrorFilter" type = "Elmah.ErrorFilterModule, Elmah" /> </ httpModules > </ system.web > < system.serviceModel > < serviceHostingEnvironment aspNetCompatibilityEnabled = "true" /> </ system.serviceModel > < system.webServer > < modules runAllManagedModulesForAllRequests = "true" > < add name = "ErrorLog" type = "Elmah.ErrorLogModule, Elmah" preCondition = "managedHandler" /> < add name = "ErrorMail" type = "Elmah.ErrorMailModule, Elmah" preCondition = "managedHandler" /> < add name = "ErrorFilter" type = "Elmah.ErrorFilterModule, Elmah" preCondition = "managedHandler" /> </ modules > < validation validateIntegratedModeConfiguration = "false" /> </ system.webServer > < runtime > < assemblyBinding xmlns = "urn:schemas-microsoft-com:asm.v1" > < dependentAssembly > < assemblyIdentity name = "MySql.Data" publicKeyToken = "C5687FC88969C44D" culture = "neutral" /> < bindingRedirect oldVersion = "0.0.0.0-6.3.7.0" newVersion = "6.3.7.0" /> </ dependentAssembly > < dependentAssembly > < assemblyIdentity name = "DotNetOpenAuth.Core" publicKeyToken = "2780ccd10d57b246" /> < bindingRedirect oldVersion = "1.0.0.0-4.0.0.0" newVersion = "4.1.0.0" /> </ dependentAssembly > < dependentAssembly > < assemblyIdentity name = "DotNetOpenAuth.AspNet" publicKeyToken = "2780ccd10d57b246" /> < bindingRedirect oldVersion = "0.0.0.0-4.3.0.0" newVersion = "4.3.0.0" /> </ dependentAssembly > < dependentAssembly > < assemblyIdentity name = "System.Net.Http" publicKeyToken = "b03f5f7f11d50a3a" culture = "neutral" /> < bindingRedirect oldVersion = "0.0.0.0-2.2.18.0" newVersion = "2.2.18.0" /> </ dependentAssembly > < dependentAssembly > < assemblyIdentity name = "EntityFramework" publicKeyToken = "b77a5c561934e089" culture = "neutral" /> < bindingRedirect oldVersion = "0.0.0.0-6.0.0.0" newVersion = "6.0.0.0" /> </ dependentAssembly > < dependentAssembly > < assemblyIdentity name = "MySql.Data" publicKeyToken = "c5687fc88969c44d" culture = "neutral" /> < bindingRedirect oldVersion = "0.0.0.0-6.3.7.0" newVersion = "6.3.7.0" /> </ dependentAssembly > </ assemblyBinding > <!-- This prevents the Windows Event Log from frequently logging that HMAC1 is being used (when the other party needs it). --> < legacyHMACWarning enabled = "0" /> <!-- When targeting ASP.NET MVC 3, this assemblyBinding makes MVC 1 and 2 references relink to MVC 3 so libraries such as DotNetOpenAuth that compile against MVC 1 will work with it. <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> </assemblyBinding> --> </ runtime > < 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 > < system.net > < defaultProxy enabled = "true" /> < settings > <!-- This setting causes .NET to check certificate revocation lists (CRL) before trusting HTTPS certificates. But this setting tends to not be allowed in shared hosting environments. --> <!--<servicePointManager checkCertificateRevocationList="true"/>--> </ settings > </ system.net > < dotNetOpenAuth > < messaging > < untrustedWebRequest > < whitelistHosts > <!-- Uncomment to enable communication with localhost (should generally not activate in production!) --> <!--<add name="localhost" />--> </ whitelistHosts > </ untrustedWebRequest > </ messaging > <!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. --> < reporting enabled = "true" /> <!-- This is an optional configuration section where aspects of dotnetopenauth can be customized. --> <!-- For a complete set of configuration options see http://www.dotnetopenauth.net/developers/code-snippets/configuration-options/ --> < openid > < relyingParty > < security requireSsl = "false" > <!-- Uncomment the trustedProviders tag if your relying party should only accept positive assertions from a closed set of OpenID Providers. --> <!--<trustedProviders rejectAssertionsFromUntrustedProviders="true"> <add endpoint="https://www.google.com/accounts/o8/ud" /> </trustedProviders>--> </ security > < behaviors > <!-- The following OPTIONAL behavior allows RPs to use SREG only, but be compatible with OPs that use Attribute Exchange (in various formats). --> < add type = "DotNetOpenAuth.OpenId.RelyingParty.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth.OpenId.RelyingParty" /> </ behaviors > </ relyingParty > </ openid > </ dotNetOpenAuth > < uri > <!-- The uri section is necessary to turn on .NET 3.5 support for IDN (international domain names), which is necessary for OpenID urls with unicode characters in the domain/host name. It is also required to put the Uri class into RFC 3986 escaping mode, which OpenID and OAuth require. --> < idn enabled = "All" /> < iriParsing enabled = "true" /> </ uri > < elmah > <!-- more information on remote access and securing ELMAH. --> < security allowRemoteAccess = "false" /> </ elmah > < location path = "elmah.axd" inheritInChildApplications = "false" > < system.web > < httpHandlers > < add verb = "POST,GET,HEAD" path = "elmah.axd" type = "Elmah.ErrorLogPageFactory, Elmah" /> </ httpHandlers > <!-- more information on using ASP.NET authorization securing ELMAH. <authorization> <allow roles="admin" /> <deny users="*" /> </authorization> --> </ system.web > < system.webServer > < handlers > < add name = "ELMAH" verb = "POST,GET,HEAD" path = "elmah.axd" type = "Elmah.ErrorLogPageFactory, Elmah" preCondition = "integratedMode" /> </ handlers > </ system.webServer > </ location > </ configuration > |

Ramon Santos
Curtir tópico
+ 0Posts
29/01/2014
Leandro Chiodini
Seria interessante voce colocar o codigo onde vc tenta simular o erro,
para darmos uma olhada na construção do try/catch
att,
Chiodini
Gostei + 0
29/01/2014
Ramon Santos
O teste que me deveria retornar um erro seria este.
1 2 3 | Sigs.BLL.Crud apoliceDB = new BLL.Crud(); Boolean insertParcela = apoliceDB.Insert("INSERT into financeiroapolicefaturamento (FINANCEIROAPOLICEFATURAMENTO_DSC_NUMEROAPOLICE,FINANCEIROAPOLICEFATURAMENTO_NUM_PARCELA, FINANCEIROAPOLICEFATURAMENTO_DEC_VALOR, FINANCEIROAPOLICE_ID----, FINANCEIROAPOLICEFATURAMENTO_DAT_VENCIMENTO) VALUES ('5000', 1, '10.00', 66, '"+Convert.ToDateTime("10/10/2014").ToString("yyyy-MM-dd")+"')"); |
O campo FINANCEIROAPOLICE_ID---- não existe e, portanto, deveria aparecer uma mensagem de erro
Gostei + 0
29/01/2014
Leandro Chiodini
Dentro do teu metodo qual o retorno que da quando voce executa a query?
at,t
Gostei + 0
29/01/2014
Ramon Santos
Gostei + 0
29/01/2014
Leandro Chiodini
Gostei + 0
30/01/2014
Ramon Santos
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public Boolean Insert(string query) { MySqlConnection objConn = ConnDbMySQL.getConn(); MySqlCommand command = new MySqlCommand(query, objConn); try { command.ExecuteNonQuery(); return true; } catch { return false; } } |
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)