FEJL PAGE SOM DUKKER OP EFTER JEG HAR TRYKKET SUBMIT BUTTON:
Server Error in '/' Application.The state information is invalid for this page and might be corrupted.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
HTML KODEN:
<%
@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" ViewStateEncryptionMode="Never" AutoEventWireup="true" CodeFile="contact.aspx.cs" Inherits="contact"
%>
<
asp:Content ID="Content1" ContentPlaceHolderID="head" Runat
="Server">
</
asp:Content
>
<
asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat
="Server">
<div id
="contact">
<
div
>
<h2>Contact Us</h2
>
<br
/>
<table
>
<!-- Name -->
<tr
>
<td align
="center">
Name:
</td
>
<td
>
<asp:TextBox ID
="txtName"
runat
="server"
Columns="50"></asp:TextBox
>
</td
>
</tr
>
<!-- Subject -->
<tr
>
<td align
="center">
Subject:
</td
>
<td
>
<asp:DropDownList ID="ddlSubject" runat
="server">
<asp:ListItem>Ask a question</asp:ListItem
>
<asp:ListItem>Report a bug</asp:ListItem
>
<asp:ListItem>Customer support ticket</asp:ListItem
>
<asp:ListItem>Other</asp:ListItem
>
</asp:DropDownList
>
</td
>
</tr
>
<!-- Message -->
<tr
>
<td align
="center">
Message:
</td
>
<td
>
<asp:TextBox ID
="txtMessage"
runat
="server"
Columns
="40"
Rows
="6"
TextMode="MultiLine"></asp:TextBox
>
</td
>
</tr
>
<!-- Submit -->
<tr align
="center">
<td colspan
="2">
<asp:Button ID="btnSubmit" runat="server" Text
="Submit"
onclick="btnSubmit_Click"
/>
</td
>
</tr
>
<!-- Results -->
<tr align
="center">
<td colspan
="2">
<asp:Label ID="lblResult" runat="server"></asp:Label
>
</td
>
</tr
>
</table
>
</div
>
</div
>
</
asp:Content
>
C#(CS) kODEN: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net.Mail; using System.Net; public partial class contact : System.Web.UI. Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { try { //Create the msg object to be sent MailMessage msg = new MailMessage (); //Add your email address to the recipients msg.To.Add("email adresse"); //Configure the address we are sending the mail from MailAddress address = new MailAddress("email adresse"); msg.From = address; //Append their name in the beginning of the subject msg.Subject = txtName.Text + " : " + ddlSubject.Text; msg.Body = txtMessage.Text;
//Configure an SmtpClient to send the mail. SmtpClient client = new SmtpClient("asmtp.unoeuro.com"); client.EnableSsl = false; //only enable this if your provider requires it //Setup credentials to login to our sender email address ("UserName", "Password") NetworkCredential credentials = new NetworkCredential("Email adresse", "kode"); client.Port = 25; client.Credentials = credentials;
//Send the msg client.Send(msg);
//Display some feedback to the user to let them know it was sent lblResult.Text = "Your message was sent!" ;
//Clear the form txtName.Text = "" ; txtMessage.Text = "" ; } catch { //If the message failed at some point, let the user know lblResult.Text = "Your message failed to send, please try again." ; } } }
|
WEB CONFIG:
<?
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
>
<
connectionStrings
>
<
add name="workConnectionstring" connectionString="Data Source=ikke oplyst;Initial Catalog=xxxxx_com_db;User ID=xxxx_com;Password=xxxx"
/>
</
connectionStrings
>
<
system.web
>
<
compilation debug="true" strict="false" explicit="true" targetFramework="4.0"
/>
<
customErrors mode="Off"
/>
<
authentication mode="Forms"
>
<
forms loginUrl="~/Account/Login.aspx" timeout="2880"
/>
</
authentication
>
<
membership
>
<
providers
>
<
clear
/>
<
add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices
"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false
"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10
"
applicationName="/"
/>
</
providers
>
</
membership
>
<
profile
>
<
providers
>
<
clear
/>
<
add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"
/>
</
providers
>
</
profile
>
<
roleManager enabled="false"
>
<
providers
>
<
clear
/>
<
add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"
/>
<
add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"
/>
</
providers
>
</
roleManager
>
</
system.web
>
<
system.webServer
>
<
modules runAllManagedModulesForAllRequests="true"
/>
</
system.webServer
>
</
configuration
>