这是我的设计页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="register.aspx.cs" Inherits="register" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="border:1px solid" align="center">
<tr><td>Username:</td><td><asp:TextBox runat="server" ID="txtUsername"></td></tr>
<tr><td>Password:</td><td><asp:TextBox runat="server" ID="txtPassword" TextMode="Password"></td></tr>
<tr><td valign="top">Address:</td><td><asp:TextBox runat="server" ID="txtAdress" TextMode="MultiLine"></td></tr>
<tr><td>Email-id:</td><td><asp:TextBox runat="server" ID="txtEmail"></td></tr>
<tr><td colspan="2" align="center"><asp:Button runat="server" ID="btnRegister"
Text="Register" onclick="btnRegister_Click" /></td></tr>
</table>
</div>
</form>
</body>
</html>
这是我的代码页:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
public partial class register : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnRegister_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage();
msg.To.Add(txtEmail.Text);
msg.From = new MailAddress("mysiteadmin@peers");
msg.Subject="thanks for registraion";
msg.Body="thanks for registraion";
SmtpClient obj = new SmtpClient();
obj.Host = "sri";obj.Send(msg);
Response.Write("<h2>Registered</h2>");
}
}
Here am getting an error below.... can you please help
服务不可用,正在关闭传输通道。服务器响应为:无法连接到 SMTP 服务器 100.64.243.189 (100.64.243.189:25),连接错误 10061 说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。异常详细信息:System.Net.Mail.SmtpException:服务不可用,正在关闭传输通道。服务器响应为:无法连接到 SMTP 服务器 100.64.243.189 (100.64.243.189:25),连接错误 10061
Source Error:
Line 21: msg.Body="thanks for registraion";
Line 22: SmtpClient obj = new SmtpClient();
Line 23: obj.Host = "sri";obj.Send(msg);
Line 24: Response.Write("<h2>Registered</h2>");
Line 25: