關於ASP.net問題,請大家幫忙,分不夠可以加!
文件:<%@ import namespace="system.web.mail" %>
<html><body>
<form runat="server" enctype="multipart/form-data">
<table border=1>
<tr><td>收件人:</td>
<td><asp:textbox runat="server" id="mailto" size=45 /></td><tr>
<td>發信者:</td>
<td><asp:textbox runat="server" id="mailfrom" size=55 /></td><tr>
<td>主題/td>
<td><asp:textbox runat="server" id="mailsubject" size=66 /></td></tr>
<tr><td>內容: </td>
<td><asp:textbox runat="server" id="mailbody" textmode="multiline" rows=9 cols=66 /><br>
<asp:radiobuttonlist runat="Server" repeatdirection="horizontal" id ="format" repeatcolumns="2">
<asp:ListItem Selected>xx</asp:listitem>
<asp:listitem>yy</asp:listitem>
</asp:radiobuttonlist>
</td>
</tr><tr><td>上傳文件</td><td>
<input type="file" runat="server" id="fil" /></td>
</table>
<asp:button runat="server" onclick="click" text="發送" />
</form>
<asp:label runat="Server" id="msg" forecolor="red" />
</body>
</html>
<script language="vb" runat="server">
sub click(sender as object,e as eventargs)
dim mail as mailmessage=new mailmessage
mail.to=mailto.text
mail.from=mailfrom.text
mail.subject=mailsubject.text
mail.body=mailbody.text
if format.selecteditem.text="xx" then
mail.bodyformat=mailformat.text
else
mail.bodyformat=mailformat.html
end if
dim fils as httppostedfile=fil.postedfile
if fils.contentlength <> 0 then
dim xy() as string=split(fils.filename, "\" )
dim name as string=xy(xy.length-1)
fils.saveAs(server.mappath(name))
dim attach as new mailattachment(server.mappath(name))
mail.attachments.add(attach)
end if
on error resume next
smtpmail.smtpserver="0101host.com"
smtpmail.send(mail)
if err.number <> 0 then
msg.text=err.description
else
msg.text="成功發送"
end if
end sub
</script>
我把此文件上傳到支持ASP。net的空間後,訪問時:為什麼會出現以下錯誤提示:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
請大家幫我,謝謝!文件沒有錯的!
问题点数:50、回复次数:12Top
1 楼denny510(小单尼)回复于 2003-12-04 11:00:03 得分 10
您确定您在服务器有运行.NET应用程序的权限吗?Top
2 楼denny510(小单尼)回复于 2003-12-04 11:02:48 得分 10
可能的原因:你使用的SMTP有效吗?一般你使用127.0.0.1就可以了。Top
3 楼javacofe(sa)回复于 2003-12-04 11:03:38 得分 0
up
Top
4 楼aero_boy(老牛)回复于 2003-12-04 11:16:25 得分 10
服务器上给你建 了虚拟目录没,问问你租宣空间的地Top
5 楼danstu(一片风)回复于 2003-12-04 14:37:09 得分 0
有啊,他支持ASP.net的,而且我上传时,也是上传到wrooot文件下
on error resume next
smtpmail.smtpserver="0101host.com"
smtpmail.send(mail)
if err.number <> 0 then
msg.text=err.description
else
msg.text="成功發送"
end if
上面这句话中的0101host.com是不是对的,我是在此网站申请的域名,空时是在别的网站申请的!
错误提示是什么回事?
Top
6 楼webdiyer(.net资源精华—www.dotneturls.com)回复于 2003-12-04 21:00:49 得分 10
打开你的web.config文件,将其中的
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
改为
<customErrors mode="Off" defaultRedirect="mycustompage.htm"/>
然后再打开上面的页面,将详细的出错信息帖上来。
Top
7 楼danstu(一片风)回复于 2003-12-05 11:55:47 得分 0
谢谢,试试先!Top
8 楼danstu(一片风)回复于 2003-12-05 12:03:51 得分 0
我的文件是这样的没有错啊,请大家帮忙啊!555555555
<configuration>
<system.web>
<globalization requestEncoding="gb2312" responseEncoding="gb2312" />
<compilation debug="true"/>
<customErrors mode="Off"/>
</system.web>
</configuration>
Top
9 楼webdiyer(.net资源精华—www.dotneturls.com)回复于 2003-12-05 12:54:22 得分 10
不是你的web.config文件有错,而是因为你原来的web.config文件中没有将customErrors设为off,因此服务器没有显示具体的错误信息,也就是什么地方出错之类的信息,你只要将customErrors设为Off,然后再打开原来的页面,具体的出错信息就会显示出来了。Top
10 楼danstu(一片风)回复于 2003-12-08 19:38:33 得分 0
下面是错误提示,我已经按您说的改了,而且从新上传了!
Server Error in '/' Application.
--------------------------------------------------------------------------------
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
谢谢了!为了这个真的很没有办法啊!Top
11 楼danstu(一片风)回复于 2003-12-12 09:34:42 得分 0
好了,决定放弃这个问题,那我如果想在本地机算机上调试,也就是能发邮件,请问朋友希要下载什么组件吗?Top
12 楼webdiyer(.net资源精华—www.dotneturls.com)回复于 2004-02-07 18:34:28 得分 0
用asp.net发邮件不需要下载任何组件,.net框架中相应的类,在System.Web.Mail命名空间中。Top




