Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 July 9th, 2010, 10:28 AM
Registered User
 
Join Date: Jun 2010
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 13, Try It out p.460

Hi

when I load the page in the browser and when i press the insert button to load the image I get this message:

Server Error in '/' Application.
Object reference not set to an instance of an object.
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.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 32:
Line 33: FileUpload FileUpload1 = (FileUpload)ListView1.InsertItem.FindControl("File Upload");
Line 34: if (!FileUpload1.HasFile || !FileUpload1.FileName.ToLower().EndsWith(".jpg"))
Line 35: {
Line 36: CustomValidator CustomValidator1 =


Source File: c:\BegASPNET\Site\ManagePhotoAlbum.aspx.cs Line: 34

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
ManagePhotoAlbum.ListView1_ItemInserting1(Object sender, ListViewInsertEventArgs e) in c:\BegASPNET\Site\ManagePhotoAlbum.aspx.cs:34
System.Web.UI.WebControls.ListView.OnItemInserting (ListViewInsertEventArgs e) +110
System.Web.UI.WebControls.ListView.HandleInsert(Li stViewItem item, Boolean causesValidation) +197
System.Web.UI.WebControls.ListView.HandleEvent(Eve ntArgs e, Boolean causesValidation, String validationGroup) +652
System.Web.UI.WebControls.ListView.OnBubbleEvent(O bject source, EventArgs e) +233
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.ListViewItem.OnBubbleEve nt(Object source, EventArgs e) +112
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(Command EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +166
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565






All the code has been entered correctly so I am really lost to why this is generating an error.

Please help

thanks
 
Old July 9th, 2010, 10:51 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hard to say without seeing your code. Can you post the markup for the page and its Code Behind?

And what happens when you run the same page from the download that comes with this book?

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!
The Following User Says Thank You to Imar For This Useful Post:
Apprentice75 (July 9th, 2010)
 
Old July 9th, 2010, 11:17 AM
Registered User
 
Join Date: Jun 2010
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi

When I use the downloaded code, I now get this error:




Server Error in '/' Application.
Access to the path 'C:\begASPNET\Site\GigPics\9b3f63ba-4ecf-4774-812a-5f9e95d99e22.jpg' is denied.
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.

Exception Details: System.UnauthorizedAccessException: Access to the path 'C:\begASPNET\Site\GigPics\9b3f63ba-4ecf-4774-812a-5f9e95d99e22.jpg' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

<%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your application:

<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>

Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

Stack Trace:

[UnauthorizedAccessException: Access to the path 'C:\begASPNET\Site\GigPics\9b3f63ba-4ecf-4774-812a-5f9e95d99e22.jpg' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +7714255
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +1162
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +61
System.IO.FileStream..ctor(String path, FileMode mode) +55
System.Web.HttpPostedFile.SaveAs(String filename) +99
System.Web.UI.WebControls.FileUpload.SaveAs(String filename) +23
ManagePhotoAlbum.LinqDataSource1_Inserting(Object sender, LinqDataSourceInsertEventArgs e) +309
System.Web.UI.WebControls.LinqDataSourceView.OnIns erting(LinqDataSourceInsertEventArgs e) +108
System.Web.UI.WebControls.LinqDataSourceView.Execu teInsert(IDictionary values) +265
System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +86
System.Web.UI.WebControls.ListView.HandleInsert(Li stViewItem item, Boolean causesValidation) +277
System.Web.UI.WebControls.ListView.HandleEvent(Eve ntArgs e, Boolean causesValidation, String validationGroup) +652
System.Web.UI.WebControls.ListView.OnBubbleEvent(O bject source, EventArgs e) +233
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.ListViewItem.OnBubbleEve nt(Object source, EventArgs e) +112
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(Command EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +166
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3614



Is this something to do with IIS settings, i've tried following the instructions on chapter 18 page 653 but to no success. As i'm having problems locating the IUSR on my machine.

Thanks
 
Old July 9th, 2010, 12:30 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Can you provide more information? Which version of IIS? Which Windows version? How did you set up the site? How do you browse to it? How did you configure the application pool and what identity does it use? And what happens when you assign the Everyone account full control temporarily?

Without this information, it's pretty difficult, if not impossible, for me to say something useful.

Cheers,

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 July 9th, 2010, 12:46 PM
Registered User
 
Join Date: Jun 2010
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi

Got it to work now.....thanks for your advice





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 rock1233 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 October 6th, 2009 12:18 PM
Chapter 13 Try It Out Pg. 460 Broken Images workib BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 September 19th, 2008 10:29 AM
Chapter 13 bwoll BOOK: Beginning Access 2003 VBA 1 June 7th, 2007 03:57 PM
Chapter 13 ElMorenito BOOK: Beginning ASP 3.0 0 January 14th, 2005 02:56 PM





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