简体   繁体   English

使用asp.net发送电子邮件错误

[英]Sending email using asp.net error

I have the following page with an email form: 我有带有电子邮件表格的以下页面:

http://www.tronitech.com/lp/impact-md.aspx http://www.tronitech.com/lp/impact-md.aspx

When you click submit, you get a 404 error page (because it jumped back a directory - loosing the /lp/) 单击提交时,您将看到一个404错误页面(因为它跳回了目录-失去了/ lp /)

The code for sending the email is in the associated .aspx.cs file in the lp directory. 发送电子邮件的代码位于lp目录中的相关.aspx.cs文件中。

Any ideas why it is loosing the sub-directory and trying to access the page in the root? 有什么想法为什么它失去了子目录并试图访问根目录中的页面?

I have the same form/structure on a page in the root and everything works fine. 我在根页面上具有相同的表单/结构,并且一切正常。

http://www.tronitech.com/Support.aspx http://www.tronitech.com/Support.aspx

Thanks 谢谢

Brett 布雷特

Here is my form code - I'm not setting anything: 这是我的表单代码-我没有设置任何内容:

<form id="MailForm" method="post" runat="server"> 

You might try changing this part of your HTML page: 您可以尝试更改HTML页面的这一部分:

<form name="MailForm" method="post" action="impact-md.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="MailForm">

To something like this: 对于这样的事情:

<form name="MailForm" method="post" action="/lp/impact-md.aspx" onsubmit="javascript:return  WebForm_OnSubmit();" id="MailForm">

Maybe the form needs to have that /lp/ in the action="" address there. 可能表单需要在action=""地址中包含该/lp/

您需要将操作=“”留空

The Problem: 问题:

Remove this from the document HEAD: 从文档HEAD中删除它:

<base href="http://www.tronitech.com/" />

By declaring a base href you are telling the browser that all relative links contained within the document start from that specified base location. 通过声明基本href,您是在告诉浏览器文档中包含的所有相对链接都从该指定基本位置开始。

W3C BASE ELEMENT W3C基础元素

The form action in your page ( action="impact-md.aspx" ) is a relative link as it does not begin with a solidus (slash). 页面中的表单动作( action="impact-md.aspx" )是相对链接,因为它不是以斜线(斜杠)开头的。 Hence, the current path is ignored and the form POST is directed by the web browser to http://www.tronitech.com/impact-md.aspx precisely as you told it to do! 因此,将按照您的指示将当前路径忽略,并由网络浏览器将POST形式直接定向到http://www.tronitech.com/impact-md.aspx

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

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