4

私はgodaddy.comを通じてサイトをホストしていますが、これは次のリンクです。

http://floridaroadrunners.com/

これは私のweb.configファイルです:

 <?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.SqlMembershipProvider" 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>

ランタイムエラーが発生します:

ランタイムエラー

説明:サーバーでアプリケーションエラーが発生しました。このアプリケーションの現在のカスタムエラー設定では、アプリケーションエラーの詳細をリモートで表示できません(セキュリティ上の理由から)。ただし、ローカルサーバーマシンで実行されているブラウザで表示することはできます。

customErrors mode="off"も設定しました。ここで何が問題になっていますか?4.0フレームワークを含むVisualStudio2010を使用しています。ありがとう!

4

4 に答える 4

2

ホストで が有効customErrorsになっている場合は、何が起こっているかを確認できるように、自分で例外をキャッチしてログに記録することを検討してください。

いくつかのオプションがあります。まずはエルマーを試す

次に、ログ ライブラリ (私は NLog が好きですが、どれでも動作します) を使用して、Global.asax.cs で Application_Error イベントをキャッチすることができます。

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);
        }

customErrors をオフにできる場合でも、これは何があっても持つべき優れた機能です。

于 2011-04-19T14:26:52.063 に答える
1

サーバーmachine.configまたはサーバーが設定applicationHost.configをオーバーライドしている可能性がありweb.configます。残念ながら、その場合は、GoDaddy のサポート ラインに連絡する以外に、実際にできることは何もありません。

于 2011-04-19T14:16:32.370 に答える
0

Global.asaxでエラーをキャッチし、例外を除いて電子メールを送信できます。

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 ExceptionHandlerクラスのMyメソッド:

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;
        }
    }
于 2011-04-19T15:33:55.443 に答える
0

customErrors modeOffは大文字と小文字が区別されると思います。最初の文字が大文字になっていることを確認してください。

于 2011-04-19T14:22:58.460 に答える