Hi guys, does anybody have any experience with Azure at all? I finally deployed a test site I built http://web-dev.azurewebsites.net/About.aspx and unfortunately there seems to be a problem when you submit the form (obviously I tested the form many times before deploying the site and it was definitely working in my localhost as I've received all the emails generated): you'll get an error message:
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>
Now, being really new to Azure, I have no idea what can cause the problem, and I'm not sure how to implement the change the error is talking about. If I look at my config file - which incidentally is called Web.config (with a capital W) - it contains the following info:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
If I ought to follow the error directive, where should I put that custom error tag, inside a new configuration tag or inside what's currently there? Presumably that addition will allow me to understand what error that is, as the error message is saying (or have I misunderstood?)
So in other words should the file look like this:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Or like this:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<customErrors mode="Off"/>
</system.web>
</configuration>
Here is the aspx.cs file that handles the form (as I mentioned before, this works absolutely fine in my localhost, that's why I'm really really frustrated!!), just in case somebody wants to see it!
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
public partial class About : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ThankYouPanel.Visible = false;//hide thank you message
if(Master is Site)
(Master as Site).ActiveClass("AboutLink");
}
protected void submitData(object sender, EventArgs e) {
//send email
string Subject = "Web development contact form submission";
string nameField = name.Value;
string titleField = title.Value;
string emailField = email.Text;
string enquiryField = enquiry.Value;
string Body = "Name: " + nameField + "<br/>" + "Title: " + titleField + "<br/>" + "Email: "+ emailField + "<br/>" + "Your enquiry: " + enquiryField;
string ToEmail = "bassabasso@gmail.com";
string SMTPUser = "bassabasso@gmail.com", SMTPPassword = "xxxxxx";
SmtpClient smtp = new SmtpClient();
//smtp.UseDefaultCredentials = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.EnableSsl = true;
MailMessage mail = new MailMessage();
mail.To.Add(ToEmail);
mail.From = new MailAddress(SMTPUser);
mail.Subject = Subject;
mail.Body = Body;
mail.IsBodyHtml = true;
//if you are using your smtp server, then change your host like "smtp.yourdomain.com"
smtp.Host = "smtp.gmail.com";
//change your port for your host
smtp.Port = 25; //or you can also use port# 587
smtp.Credentials = new System.Net.NetworkCredential(SMTPUser, SMTPPassword);
//smtp.Host = "smtp.gmail.com";
smtp.Send(mail);
//hide form and show thank you message with no panel
//contactForm.Attributes.Add("class", contactForm.Attributes["class"] + " hidden");
//thankYouMsg.Attributes.Add("class", thankYouMsg.Attributes["class"] + " active");
//hide form and show thank you msg with panel controller
ContactFormPanel.Visible = false;
ThankYouPanel.Visible = true;
}
}
And here is the aspx file:
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="About.aspx.cs" Inherits="About" Title="Untitled Page" UnobtrusiveValidationMode="None" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="headingPlaceholder" Runat="Server">
<h1>About this site</h1>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="introPlaceholder" Runat="Server">
<p>This site if for people who hate straight lines (check the <a href="Home.aspx" class="link">home page</a> if you're not sure what it this means.) I don't like blogs because you have to maintain them, so I chose to have a simple site to make a note of all the good things I learned in my development career to date. It doesn't necessarily mean that I endorse all that, but it surely turned out to be useful in many occasions, so, not to forget any of it, here is not-a-so-concise memorandum.</p>
<p> In the unlikely event that you come across this website, feel free to use/abuse any of the code for your own projects (incidentally any quote is certainly appreciated, if nothing it will increase the Google ranking of the site). </p>
<p>The code will be posted in the form of excerpts, so no downloads or things like that, just copy and paste it if you need to.</p>
<p>All the code has been tested and used (unless I specifically say it hasn't), and it definitely works, but still, should you find any imprecision, feel free to let me know</p>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="contentPlaceholder" Runat="Server">
<asp:Panel ID="ThankYouPanel" runat="server">
<div class="thankYouMsg" id="thankYouMsg" runat="server">
<h2>Thank you for your feedback.</h2>
</div>
</asp:Panel>
<asp:Panel ID="ContactFormPanel" runat="server">
<div class="contactForm" id="contactForm" runat="server">
<h2>Contact me</h2>
<div id="Div1" class="form" runat="server">
<div class="control-group">
<label class="control-label" for="title">Title</label>
<div class="controls">
<select id="title" runat="server">
<option>Select</option>
<option>Mr</option>
<option>Ms</option>
<option>Miss</option>
<option>Mrs</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="name">Name</label>
<div class="controls">
<input runat="server" type="text" id="name" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">Email</label>
<div class="controls">
<%--<input id="email" runat="server" type="text" />--%>
<asp:TextBox ID="email" runat="server"></asp:TextBox>
</div>
</div>
<div class="control-group">
<label class="control-label" for="enquiry">Enquiry<span>*</span></label>
<div class="controls">
<textarea id="enquiry" runat="server" type="text"></textarea>
<%--<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>--%>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Please enter your message" ControlToValidate="enquiry"></asp:RequiredFieldValidator>
</div>
</div>
<div class="submitButton">
<input id="submitForm" type="submit" value="Submit" runat="server" onserverclick="submitData">
<div class="clear"></div>
</div>
</div>
</div>
</asp:Panel>
</asp:Content>