简体   繁体   中英

Code runs fine on localhost but doesn't execute on gatorhost

I wrote a small website in VWD. I am running it on my home machine using the localhost features of VWD. It runs flawlessly.

Now the backstory. I had a linux server with gatorhost. I had them switch my domain and my server type to windows because i decided to learn asp.net(c#). I had a million problems with them hours on the phone. Issues with unable to connect when you search for my domain and my e-mail features and ftp features where all messed up took them hours to figure it out in multiple calls and tickets.

So now i think i got it all working i load my site through VWD onto my server (www.contentiousweb.com) All of my front end code works fine as far as form validation and links.

When i hit my submit buttons that would execute my c# code nothing happens at all. not a thing. When the forms are filled out wrong the validation works. I got no errors or anything. i like dont know where to start. Is it my code there server how much can i rely on VWD in being right because i cannot rely on my self lol.

Webconfig file. (i swapped out my pw and e-mail)

<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="Ralph &lt;********@hotmail.com&gt;">
<network enableSsl="true" host="smtp.live.com" userName="*************@hotmail.com" password="***********" port="587" />
</smtp>
</mailSettings>
</system.net>

Bellow is the button.

protected void Button1_Click(object sender, EventArgs e)
{

if (Page.IsValid)
{
string fileName = Server.MapPath("_TextFiles/ContactForm.txt");
string mailBody = File.ReadAllText(fileName);

mailBody = mailBody.Replace("##Name##", nameBox.Text);
mailBody = mailBody.Replace("##Email##", emailBox.Text);
mailBody = mailBody.Replace("##Subject##", subBox.Text);
mailBody = mailBody.Replace("##Message##", MsgField.Text);

MailMessage myMessage = new MailMessage();
myMessage.Subject = "Response from  Contact Page";
myMessage.Body = mailBody;

myMessage.From = new MailAddress("******", "Contact");
myMessage.To.Add(new MailAddress("******", " Server"));

SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.Send(myMessage);

Message.Visible = true;
ContactTable.Visible = false;
System.Threading.Thread.Sleep(5000);

}
}

}

Any help would be greatly appresciated. i am new and learning but with my experince and problems with hostgator i think that it is something on there end because everything else has been. i am clueless.

Please let me know if there is anymore information i can provide. Thank you for any help

In my own troubleshooting i found this error just now using mozila dev tools.

[18:03:28.399] Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500 @ http://contentiousweb.com/ScriptResource.axd?d=EJBSV2JIVC3wCtbtVqDWEZfeOsqUeA-l1kZnjjZKvx15e0cjnzPdj4H78hvszmtfrIhAM96VdUstdDjn1xGAbsydMzIjEQeNWDOz2tihnjEjxDW5esVemHLoHR01oIyUBoZTNPd7atx4-EPBnuVlWYbQIeLdoH_eBXy1j9kav6ac2ptv4Cl8sraaDBGXntVH0&t=ffffffff940d030f:1507

Thanks for any help i am still looking for answers my self.

I got it going. After talking with gatorhost on the phone for four hours we determined that the smtp information they had provided me would not work. They had me change my host to

<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network  host="localhost" userName="*************@hotmail.com" password="***********" port="25" />
</smtp>
</mailSettings>
</system.net>

And now it all works no errors. Thank you everyone who helped with ideas.

I don't see in your code assigning the port number or credentials?

This code should work

// SMTP options
string Host = "smtp.mail.emea.microsoftonline.com";
Int16 Port = 587;
bool SSL = true;
string Username = "myname@mydomain.com";
string Password = "mypassword";

// Mail options
string To = "reciever@recieverdomain.com";
string From = "myname@mydomain.com";
string Subject = "This is a test";
string Body = "It works!";

MailMessage mm = new MailMessage(From, To, Subject, Body);
SmtpClient sc = new SmtpClient(Host, Port);
NetworkCredential netCred = new NetworkCredential(Username, Password);
sc.EnableSsl = SSL;
sc.UseDefaultCredentials = false;
sc.Credentials = netCred;

try
{
   Console.WriteLine("Sending e-mail message...");
  sc.Send(mm);
}
catch (Exception ex)
{
   Console.WriteLine("Error: {0}", ex.ToString());
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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