简体   繁体   中英

Trouble debugging asp.net web service

I'm having trouble figuring out why my web service is not working correctly when called from my asp.net application in production only.

I am able to run my asp.net application locally, calling the web service (in production) and it completes correctly.

I am able to modify the web.config to allow me to use the test form on the production web service and it calls correctly.

I'm calling the web service in a shared dll, and I already check that I am actually getting the updated dll.

This is a very basic web service to log any exceptions on our sites that aren't handled elsewhere. I'm adding additional parameters to it, and also moving it to another project so it is grouped with more of our web services. It is in it's own asmx file called ExceptionServices

My shared dll has a class ErrorHandler which calls (at this point, a test method) TestEmail(string to) and all that does is sends me an email.

Like I said, when running my app locally, it calls the production web service and all is good.

I am running in a hosted environment and am unable to install the remote debugging tools so I cannot step through the production code (unless anybody knows any tricks).

It just seems like this should work ( banging head on keyboard )...

Here is my basic web method:

    [WebMethod]
    public void TestEmail(string to)
    {
        MailMessage mm = new MailMessage("no-reply@mydomain.com", to, "test", "body here");
        SmtpClient client = new SmtpClient("localhost"); // already tried tweaking smtp server, and all my options work when I use the test form
        client.Send(mm);
    }

ErrorHandler class in the shared dll

public class ErrorHandler
{
    public static void ThrowError(Exception ex, string sitename, string ip, string username)
    {
        //if (ip != "127.0.0.1") // exclude local errors when developing
        {
            EILib.ExceptionServices.EIExceptionHandler eh = new EILib.ExceptionServices.EIExceptionHandler();
            eh.TestEmail("senloe@....com");
        }
    }
}

and finally my global.asax where it all begins:

    protected void Application_Error(object sender, EventArgs e)
    {
        //Get the Error.        
        System.Exception anError = Server.GetLastError();
        EILib.ErrorHandler.ThrowError(anError, "mydomain.com", EILib.Utilities.GetUserHostAddress(Request), User.Identity.Name);
        ....
    }

Verify that the SMTP service is running on your production server. Check that it is configured to allow the default credentials (a hosting company might well require credentials for email). Check that the service is configured to receive mail from from the local computer (as opposed to using one of the pickup directory delivery methods).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM