Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 30th, 2011, 08:47 AM
Authorized User
 
Join Date: May 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Handling Exceptions - invalid email address

Hello,

I'm on chapter 18 page 661, and I'm trying to recreate an error with an invalid email address, it does not go to the 'yellow screen of death', it goes to my home page. My behind code is as follows:

Code:
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;
publicpartialclassDemos_ExceptionHandling : BasePage
{
protectedvoid Page_Load(object sender, EventArgs e)
{
MailMessage myMessage = newMailMessage();
myMessage.Subject = "Exception Handling Test";
myMessage.Body = "Test message body";
myMessage.From = newMailAddress("paulhudson2005.gmail.com");
myMessage.To.Add(newMailAddress("[email protected]"));
SmtpClient mySmtpClient = newSmtpClient();
mySmtpClient.Send(myMessage);
Message.Text = "Message sent";
}
}
What am I doing wrong?

Thanks in advance

Paul
 
Old April 30th, 2011, 08:54 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Paul,

Can you post the code for your web.config and Global.asax files? (Make sure to remove sensitive information from the config file first).

Also, when you post code, can you please past it in Notepad first? This forum doesn't like colored code for some reason...

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old April 30th, 2011, 09:26 AM
Authorized User
 
Join Date: May 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default web.config file & global asax files

Hi Imar,

Here's the files you asked for:

web.config

<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="PlanetWroxConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\PlanetWrox.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
<add name="PlanetWroxEntities" connectionString="metadata=res://*/App_Code.PlanetWrox.csdl|res://*/App_Code.PlanetWrox.ssdl|res://*/App_Code.PlanetWrox.msl;provider=System.Data.SqlCl ient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\PlanetWrox.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
<profile>
<properties>
<add name="FirstName" />
<add name="LastName" />
<add name="DateOfBirth" type="System.DateTime" />
<add name="Bio" />
<add name="FavouriteGenres" type="System.Collections.Generic.List`1[System.Int32]" />
</properties>
</profile>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, &#xD;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9; Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
</providers>
</membership>
<roleManager enabled="true" />
<authentication mode="Forms" />
<pages theme="Management">
<controls>
<add tagPrefix="Wrox" tagName="Banner" src="~/Controls/Banner.ascx" />
</controls>
</pages>
<compilation debug="false" targetFramework="4.0">
<assemblies>
<add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
<buildProviders>
<add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesig nerBuildProvider" />
</buildProviders>
</compilation>
</system.web>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="Paul Hudson &lt;[email protected]&gt;">
<network enableSsl="true" userName="[email protected]" password="###########" host="smtp.gmail.com" />
</smtp>
</mailSettings>
</system.net>
<location path="Management">
<system.web>
<authorization>
<allow roles="Managers" />
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="My Profile.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
<location>
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
<location path="NewPhotoAlbum.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>

Global.asax file:

I can't locate this file, is this an optional file you create?

Thanks

Paul
 
Old April 30th, 2011, 09:56 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Could it be a permissions issue? You block access to all pages:

<location>
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>

What happens when you type the page's address in the address bar after you login?

The Global.asax file gets created a little later in this chapter; I didn't know where exactly, so I didn't realize you don't have it... ;-)

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
validate email address dartcoach Javascript 0 April 28th, 2008 12:58 PM
C# handling SQL Server exceptions booksnore2 General .NET 3 September 16th, 2006 09:40 AM
Valid Email Address...... muskaanbajaj VB.NET 1 November 22nd, 2005 11:38 AM
Incoming Email handling BaNSHee SQL Server ASP 0 April 6th, 2005 05:00 AM
Email handling rajanikrishna Beginning PHP 3 October 10th, 2003 01:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.