&n."/> &n."/> &n"/>
خرید بک لینک
سلام دوستان من تازه وارد MVC شدم. یه صفحه تماس با ما طراحی کردم اما اطلاعاتش رو پست نمیکنه.نمیدونم چرا؟
کد HTML:

<form action="/Home/test" method="post">
         

                <div class="form-group">
                    <label for="Name">Name</label>
                    <input type="text" class="form-control" id="Name">

                </div>
                <div class="form-group">
                    <label for="email">Email address:</label>
                    <input type="email" class="form-control" id="email">
                </div>

                <div class="form-group">
                    <label for="Message">Message:</label>
                    <textarea class="form-control" rows="5" id="Message"></textarea>
                </div>


                <div>
                    <button type="submit"
                            class="btn btn-success">

                        Send
                    </button>
                </div>

        </form>


اینم کد کنترلر:
   [HttpGet]
public ActionResult test()
{



return View();
}


[HttpPost]
public ActionResult test(string Email, string Name, string Message)
{
if (Message != string.Empty && Message != null)
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient();
SmtpServer.Credentials = new System.Net.NetworkCredential(("[email protected]" ), ("ghffhgfh"));
SmtpServer.Port = 25;
SmtpServer.Host = "mail.defender20.ir";
mail.From = new MailAddress((Email));
mail.To.Add("[email protected]");
mail.Subject = ("ارسال پیام");

System.Net.Mail.AlternateView alternateViewtxt = System.Net.Mail.AlternateView.CreateAlternateViewF romString(Email, null, "text/html");
mail.AlternateViews.Add(alternateViewtxt);
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.OnSuccess;

SmtpServer.Send(mail);
ViewBag.Message = "پیام شما با موفقیت ارسال خواهد شد به زودی پاسخ گوی شما خواهیم بود";
}
catch (Exception ex)
{
ModelState.Clear();
ViewBag.Message = "خطا: " + ex.Message.ToString();
}

}


return View();
}

برچسب: نویسنده: خنج تاريخ: شنبه 30 ارديبهشت 1396 ساعت: 10:02

صفحه بندی