Wrox Programmer Forums
|
BOOK: Beginning ASP.NET Web Pages with WebMatrix
This is the forum to discuss the Wrox book Beginning ASP.NET Web Pages with WebMatrix by Mike Brind, Imar Spaanjaars ; ISBN: 978-1-1180-5048-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET Web Pages with WebMatrix 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 January 12th, 2012, 12:23 PM
Registered User
 
Join Date: Jan 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chap 1 - Error Message 404.8

I ran into Error Message 404.8 following along in chapter 1 the first time I tried to view in my browser the first page I had created with webmatrix. I couldnt find anything in the book about it and I couldnt find a thread here yesterday with a fix. I figured I would save the next person the hassle of tracking a solution down.

The error message description was "The request filtering module is configured to deny a path in the url that contains a hiddensegment section". My requested url was http://localhost:333963/App_Data/page.cshtml

I found the general solution here:

http://support.microsoft.com/kb/942047


This is what I did to correct mine on both my desktop and laptop:

1. Clicked start and searched for applicationhost.config
2. Right click on applicationhost.config and select properties to find and copy path.
3. Click Start, type Notepad in the Start Search box, right-click Notepad, and then click Run as administrator.
4. On the File menu, click Open, and paste the path and click open (make sure you are viewing all files not just .txt)
5. Select and open ApplicationHost.config
6. In the ApplicationHost.config file search (crtl-F) for "hidden" or "hiddensegments" which will locate the <hiddenSegments> element.
7. Microsoft says in the <hiddenSegments> element, you can either delete the entry that matches the directory that is specified in the requested URL.

Instead of deleting code I edited the line to read:

<!-- add segment="App_Data" / -->


8. On the File menu, click Save.
9. Exit Notepad.

Hope that helps someone.
 
Old January 12th, 2012, 01:50 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,

While your fix does work, it's far from the ideal solution. The short explanation is: move page.cshtml out of App_Data into the root of the site, or any folder other than the root (and some other reserved folders explained in Chapter 1).

The long explanation:

App_Data is designed to store data that is only accessible to your code that runs on the server. You use it for databases, XML files and other files you want to read from code but not expose to your end users directly over HTTP. By default, as you found out, access to this folder is blocked. By removing this restriction, anyone can download files from that folder, even files that may contain sensitive information such as databases.

So, storing web files in App_Data and then opening that folder up to end users is not the right way to do it if you want to build a secure system. Instead, revert your changes in the config file, move page.cshtml to the root or some other folder and you're good to go.

Hope this helps.

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!
The Following User Says Thank You to Imar For This Useful Post:
Mike Brind (January 12th, 2012)
 
Old January 12th, 2012, 07:24 PM
Registered User
 
Join Date: Jan 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thanks

That makes a lot more sense - it worked great.





Similar Threads
Thread Thread Starter Forum Replies Last Post
catch 404 error danielnixon ASP.NET 2.0 Basics 1 May 1st, 2008 06:57 PM
Error 404 SeniorNSU BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 August 30th, 2006 11:09 AM
404 error DARSIN .NET Framework 2.0 1 March 24th, 2005 06:04 AM
404 error scrowler Pro PHP 1 December 19th, 2004 11:36 AM
Error 404 jackps Dreamweaver (all versions) 2 January 15th, 2004 09:29 AM





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