I am hosting a site through godaddy.com and this is the link:
http://floridaroadrunners.com/
and this is my web.config file:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<customErrors mode="Off"/>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMemb开发者_开发技巧ershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I am getting runtime error:
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
I have also set the customErrors mode = "off". What is wrong here? I am using Visual Studio 2010 with 4.0 framework in it. Thanks!
If your host has enabled customErrors
, you might consider catching and logging the exception yourself so you can see what's going on.
There are a couple options. First, try Elmah
Second, you could use your logging library (I like NLog, but any will work), and catch the Application_Error event in Global.asax.cs.
protected void Application_Error(object sender, EventArgs e)
{
//first, find the exception. any exceptions caught here will be wrapped
//by an httpunhandledexception, which doesn't realy help us, so we'll
//try to get the inner exception
Exception exception = Server.GetLastError();
if (exception.GetType() == typeof(HttpUnhandledException) && exception.InnerException != null)
{
exception = exception.InnerException;
}
//get a logger from the container
ILogger logger = ObjectFactory.GetInstance<ILogger>();
//log it
logger.FatalException("Global Exception", exception);
}
This is a good feature to have no matter what, even if you're able to get customErrors turned off.
The server's machine.config
or applicationHost.config
is likely overriding your web.config
settings. Unfortunately there's nothing you can really do if that's the case, short of contacting GoDaddy's support line.
customErrors mode
value Off
is case sensitive I think. Please check that you have the first character capitalized.
You can catch the error in you Global.asax and sending an email with the exception.
In Global.asax.cs:
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
Exception ex = Server.GetLastError();
ExceptionHandler.SendExceptionEmail(ex, "Unhandled", this.User.Identity.Name, this.Request.RawUrl);
Response.Redirect("~/ErrorPage.aspx"); // So the user does not see the ASP.net Error Message
}
My method in My ExceptionHandler Class:
class ExceptionHandler
{
public static void SendExceptionEmail(Exception ex, string ErrorLocation, string UserName, string url)
{
SmtpClient mailclient = new SmtpClient();
try
{
string errorMessage = string.Format("User: {0}\r\nURL: {1}\r\n=====================\r\n{2}", UserName, url, AddExceptionText(ex));
mailclient.Send(ConfigurationManager.AppSettings["ErrorFromEmailAddress"],
ConfigurationManager.AppSettings["ErrorEmailAddress"],
ConfigurationManager.AppSettings["ErrorEmailSubject"] + " = " + ErrorLocation,
errorMessage);
}
catch { }
finally { mailclient.Dispose(); }
}
private static string AddExceptionText(Exception ex)
{
string innermessage = string.Empty;
if (ex.InnerException != null)
{
innermessage = string.Format("=======InnerException====== \r\n{0}", ExceptionHandler.AddExceptionText(ex.InnerException));
}
string message = string.Format("Message: {0}\r\nSource: {1}\r\nStack:\r\n{2}\r\n\r\n{3}", ex.Message, ex.Source, ex.StackTrace, innermessage);
return message;
}
}
精彩评论