我已取得一些进展,现在我收到此错误
无法将消息发送到smtp服务器。传输错误代码是0x800ccc15
远程服务器返回错误:(500)内部服务器错误。 描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
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
下面是我认为导致错误的代码部分
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
答案 0 :(得分:0)
因为远程服务器由于某种原因未接受您的请求。我会尝试手动打入你的代码生成的一些网址,看看他们是否给你任何想法。或者联系负责cc.com的服装,了解如何正确提交远程请求。
通过猜想,假设它是.ASPX,它可能期望您的Web客户端处理会话cookie,并且当您没有它时它可能会崩溃。但是从这里可以肯定地说不出来。