Hi i hope someone can help me, Ive created a contact form. But when i update the email adress in the controller (using a web editor) the changes dont work.
Do i have to rebuild in order to change this ?
I tried editing the Controller directly in html on the webserver under controllers. But i have noticed that this doesn't work . When i edited the controller in Visual studio and previewed the publishing i saw that there is also a dll created...So i guess i have to do this in Visual studio.
using Marstrand.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Web;
using System.Web.Mvc;
using Umbraco.Web.Mvc;
namespace Marstrand.Controllers
{
public class ContactFormSurfaceController : SurfaceController
{
// GET: ContactFormSurface
public ActionResult Index()
{
return PartialView("ContactForm", new ContactFormViewModel());
}
[HttpPost]
public ActionResult HandleFormSubmit(ContactFormViewModel model)
{
if (!ModelState.IsValid)
return CurrentUmbracoPage();
//Hier komt de code om mail te verzenden
MailMessage message = new MailMessage();
message.To.Add("[email protected]");
message.Subject = "ContactFormulier via uw website TEST";
message.From = new System.Net.Mail.MailAddress(model.EmailAdres, model.VoorNaam + " " + model.AchterNaam);
message.Body = "Voornaam: " + model.VoorNaam + "<br />" + "Achternaam: " + model.AchterNaam + "<br />" + "Email adres: "
+ model.EmailAdres + "<br />" + "Telefoon: " + model.telefoonNummer + "<br />" + "<br />" + "<br />" + model.Bericht;
message.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Send(message);
TempData["success"] = true;
return RedirectToCurrentUmbracoPage();
}
}
}
If you place your controllers in the /App_Code folder they get compiled at runtime. That way you can make live changes using a web editor/FTP and they will run instantly.
But if you have your controllers outside /App_Code, like for instance/Controllers, your code needs to combine (build the dll:s) and then you need to publish the dll with the same name as your project/solution for your changes to take affect. That probably why you see your changes in Visual Studio, since it builds when you run your project.
So, either move your controllers to the /App_Code folder or compile locally and publish the dll:s.
Contact form Surface Controller
Hi i hope someone can help me, Ive created a contact form. But when i update the email adress in the controller (using a web editor) the changes dont work. Do i have to rebuild in order to change this ?
Best Regards,
Jaco
Hi Jaco,
Can you provide code example?
What do you mean "in the controller (using a web editor)"?
THanks,
Alex
Hi Alex,
I tried editing the Controller directly in html on the webserver under controllers. But i have noticed that this doesn't work . When i edited the controller in Visual studio and previewed the publishing i saw that there is also a dll created...So i guess i have to do this in Visual studio.
Thanks,
Jaco
Hi jaco.
If you place your controllers in the /App_Code folder they get compiled at runtime. That way you can make live changes using a web editor/FTP and they will run instantly.
But if you have your controllers outside /App_Code, like for instance/Controllers, your code needs to combine (build the dll:s) and then you need to publish the dll with the same name as your project/solution for your changes to take affect. That probably why you see your changes in Visual Studio, since it builds when you run your project.
So, either move your controllers to the /App_Code folder or compile locally and publish the dll:s.
Hope this makes sense!! Best of luck!
Hi Dennis,
Thank you very much :) but can i just create a folder named App_Code and move the controller to this folder ?
Yes, you can jaco.
Did it work out for you?
Hi Jaco,
Yes, you can just create App_Code folder and move the controller there.
"App_Code" - reserved asp.net name of folder for compiled at runtime.
Hope it will help you.
Thanks,
Alex
is working on a reply...