locked
Logging to database is not working RRS feed

  • Question

  • User-1766995870 posted

    Hi,

    Am using Enterprise library 4.0 for logging exceptions to SQL server database. The code is working fine if I run my asp.net application from the Visual studio IDE.However if I publish the site and host it on IIS, then my application is not logging the errors to database.Here is the page load event of my application.Kindly help me in finding out the error.

    Thanks in advance

    Srinivas

     protected void Page_Load(object sender, EventArgs e)
     {
                try
                {
                    //If exception occurs due to unauthorized access
                    if ((Request.QueryString["Unauthorized"] != null) && (Request.QueryString["Unauthorized"].Equals("Y")))
                    {
                            lblErrorMessage.Text = "You are not authorized to view this page";
                            //Get the user and machine names                       
                            string strUserName = User.Identity.Name;
                            string strMachineName = System.Environment.MachineName;
                            
                            //Raise Error
                            throw new System.UnauthorizedAccessException("Unauthorized access--User Name:" + strUserName + "--Machine Name:" + strMachineName);
                    }
      catch (UnauthorizedAccessException oEx)
                   {
                       Exception exceptionToThrow;
                       ExceptionPolicy.HandleException(oEx, "ExceptionPolicy", out exceptionToThrow);
                   }
            }
    }


     

    Wednesday, August 4, 2010 2:59 AM

All replies

  • User-9639071 posted

     

    check your connection string and remove "Integrated security"  and then check

    Wednesday, August 4, 2010 5:54 AM
  • User-1802908944 posted

    check here


    http://connectionstrings.com



    Wednesday, August 4, 2010 9:14 AM
  • User-1766995870 posted

     

    check your connection string and remove "Integrated security"  and then check

     

    Hi virender

    Thanks for the reply. I am not using "Integrated Security" in my connection string. My connection string is

    <add name="MyLogging" providerName="System.Data.SqlClient" connectionString="server=MyServer;database=MyLogging;UID=sa;PWD=password"/>

    Srinivas

    Wednesday, August 4, 2010 9:36 AM