开发者

why am i getting a 500 error in this code

I have made some progress and now i am getting this error

the message could not be sent to the smtp server. the transport error code was 0x800ccc15

The remote server returned an error: (500) Internal Server Error. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (500) Internal Server Error.

Source Error: 


Line 62:     Private Function HttpContent(ByVal url As String) As String
Line 63:         Dim objRequest As Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
Line 64:         Dim sr As New IO.StreamReader(objRequest.GetResponse().GetResponseStream())
Line 65:         Dim result As String = sr.ReadToEnd()
Line 66:         sr.Close()


Source File: C:\Inetpub\wwwroot\AB.com\wwwroot\bookingrequest\booking.aspx.vb    Line: 64 

Stack Trace: 


[WebException: The remote server returned an error: (500) Internal Server Error.]
   System.Net.HttpWebRequest.GetResponse() +5375997
   _Default.HttpContent(String url) in C:\Inetpub\wwwroot\ABCdestionations.com\wwwroot\bookingrequest\booking.aspx.vb:64
   _Default.Button1_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\ABCdestionations.com\wwwroot\bookingrequest\booking.aspx.vb:37
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Heres the portion of the code that i think is causing the error

 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        If Page.IsValid Then
     开发者_StackOverflow社区       SqlDataSource1.Insert()
            Dim x As String
            x = "http://www.cc.com/bookingrequest/confirm.aspx?date=" & HttpUtility.UrlEncode(now.Text) & "&tfname=" & HttpUtility.UrlEncode(lofname1.Text) & "&tlname=" & HttpUtility.UrlEncode(lolname1.Text) & "&comp=" & HttpUtility.UrlEncode(Request.QueryString("comp")) & "&land=" & HttpUtility.UrlEncode(land.Text)
            Dim mail As New MailMessage()
            mail.To = locemail.Text
            mail.From = "info@cc.com"
            mail.Subject = "Booking Request for " + locfname.Text + " " + loclname.Text
            Dim url As String
            url = "http://www.cc.com/bookingrequest/email.aspx?date=" + now.Text + "&tfname=" + lofname1.Text + "&tlname=" + lolname1.Text + "&comp=" + Request.QueryString("comp") & "&land=" & HttpUtility.UrlEncode(land.Text)
            mail.Body = HttpContent(url) + Environment.NewLine + "If You Can't See This E-mail, Please Click The Link.  " + x
            mail.BodyFormat = MailFormat.Html
            mail.UrlContentBase = url
            SmtpMail.SmtpServer = "mail.cc.com"
            SmtpMail.Send(mail)



            Dim mail1 As New MailMessage()
            mail1.To = "info@CC.com"
            mail.Cc = "JS@cc.com"
            mail1.From = "BookingRequest@cc.com"
            mail1.Subject = "Booking Request for " + locfname.Text + " " + loclname.Text + " made by " & Request.QueryString("comp")
            mail1.Body = HttpContent(url) + Environment.NewLine + "If You Can't See This E-mail, Please Click The Link.  " + x
            mail1.BodyFormat = MailFormat.Html
            mail1.UrlContentBase = url
            SmtpMail.SmtpServer = "mail.cc.com"
            SmtpMail.Send(mail1)

            Response.Redirect("http://www.cc.com/bookingrequest/confirm.aspx?date=" + now.Text + "&tfname=" + lofname1.Text + "&tlname=" + lolname1.Text + "&comp=" + Request.QueryString("comp") & "&land=" & HttpUtility.UrlEncode(land.Text))

        End If

    End Sub

    Private Function HttpContent(ByVal url As String) As String
        Dim objRequest As Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
        Dim sr As New IO.StreamReader(objRequest.GetResponse().GetResponseStream())
        Dim result As String = sr.ReadToEnd()
        sr.Close()
        Return result
    End Function


Because the remote server is not accepting your request for some reason. I would try to manually punch in a few of the urls your code generates and see if they give you any idea. Or to contact the outfit in charge of cc.com to see how to properly submit remote requests.

By conjecture, given it is .ASPX, it could be expecting your web client to handle session cookies and it could be crashing when you don't have them. But there isn't much one can tell for certain from here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜