简体   繁体   English

为什么我在这段代码中收到 500 错误

[英]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.消息无法发送到 smtp 服务器。 the transport error code was 0x800ccc15传输错误代码为 0x800ccc15

The remote server returned an error: (500) Internal Server Error.远程服务器返回错误:(500) 内部服务器错误。 Description: An unhandled exception occurred during the execution of the current web request.说明:在执行当前 web 请求期间发生未处理的异常。 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
            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.我会尝试手动输入您的代码生成的一些 url,看看它们是否给您任何想法。 Or to contact the outfit in charge of cc.com to see how to properly submit remote requests.或者联系cc.com的负责人,看看如何正确提交远程请求。

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.据推测,鉴于它是.ASPX,它可能期望您的 web 客户端处理 session cookies,当您没有它们时它可能会崩溃But there isn't much one can tell for certain from here.但是从这里没有什么可以确定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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