?
Solved

is this ok to do? - Filenotfound.aspx and master page

Posted on 2008-06-13
9
Medium Priority
?
480 Views
Last Modified: 2008-06-16
i'm working on an asp.net app that has a FileNotFound.aspx for error 404. This is attached to a Master page and this master page is on every page.

I ran a .net porfiler and it shows this filenotfoundpage..trying to be rendered or being called. Whatever it was, it showed it as one of the bottlenecks.

I created a new filenotfound.aspx with no master page. And profiler showed it as less bottlneck.

Is this normal to create filenotfound.aspx with master page? why is the profiler shows this aspx page as being loaded or called..is it because it's attached to the master page??

<customErrors mode="Off" defaultRedirect="~/Error.aspx">
			<error statusCode="404" redirect="~/FileNotFound.aspx"/>
			<error statusCode="500" redirect="~/Error.html"/>
		</customErrors>

Open in new window

0
Comment
Question by:Camillia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 18

Expert Comment

by:Gary Davis
ID: 21783624
Hopefully your FileNotFound.aspx is not called much. If it is, you probably have something on your pages like a broken image/css/js causing it to be called a lot. Have the FileNotFound.aspx page log why it is being called - what request is causing the 404? That will help you pinpoint the issue. I assume it is OK to have a FNF page use Master Pages.

Gary Davis
0
 
LVL 7

Author Comment

by:Camillia
ID: 21783750
>>Have the FileNotFound.aspx page log why it is being called
How can I do that??

>> If it is, you probably have something on your pages like a broken image/css/js causing it to be called a lot.

How so? how is this related to FNF being called? so, maybe something is missing in that master page that this FNF uses??
0
 
LVL 18

Expert Comment

by:Gary Davis
ID: 21783815
I think the FNF will be entered with a querystring containing the failing url.

Even page components will fire off the FNF page even though the user may never see them (only if the main page itself is not found).

Yes, if the Master page tries to get a css file (for example) that causes a 404 Not Found, every page that uses that Master page will generate one call to the FNF.

Gary
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Author Comment

by:Camillia
ID: 21783868
>> Yes, if the Master page tries to get a css file (for example) that causes a 404 Not Found, every page that uses that Master page will generate one call to the FNF.

 I get this. Makes sense. Thanks. I thought 404 is for when an aspx pages are not found.

>> I think the FNF will be entered with a querystring containing the failing url.
Not sure what this means. I should enter http://localhost/whateversite/filenotfound.aspx ?

0
 
LVL 18

Expert Comment

by:Gary Davis
ID: 21783979
You should modify filenotfound.aspx to write it's querystring somewhere or perhaps check the web logs; maybe it's there already. Then when the aspx page runs for the 404's you can check the logs to see what's causing it.
0
 
LVL 7

Author Comment

by:Camillia
ID: 21783996
sorry gary, i know i'm beating this one to death...can u give me  an example?
0
 
LVL 18

Accepted Solution

by:
Gary Davis earned 2000 total points
ID: 21785372
This is FileNotFound.aspx. The errors come into this page with QueryString["aspxerrorpath"] set to the Url causing the 404 Not Found. This is written to a log file with a timestamp and the Referrer so you can see the referring page that caused the error.

This is an example:

  http://localhost:50262/FileNotFound.aspx?aspxerrorpath=/Missing.aspx

The is what is written to the Errors.log:

  6/14/2008 9:42:28 AM - File Not Found: /Missing.aspx; Referrer: http://localhost:50262/Default.aspx

On my Default.aspx, I had a hyperlink to the Missing.aspx page.

Gary
using System;
using System.IO;
 
namespace WebApplication2
{
    public partial class FileNotFound : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // Log 404 Not Found's to Errors.log file
            string fileName = Server.MapPath("/Errors.log");
            string output = string.Format("{0} - File Not Found: {1}; Referrer: {2}\n",
                DateTime.Now, Request.QueryString["aspxerrorpath"], Request.UrlReferrer);
 
            using (StreamWriter sw = new StreamWriter(fileName, true))
            {
                sw.Write(output);
            }
 
            //TODO: Format rest of page to display to user
        }
    }
}

Open in new window

0
 
LVL 7

Author Comment

by:Camillia
ID: 21787113
thanks gary. Let me look. Thanks for sticking with this.
0
 
LVL 7

Author Comment

by:Camillia
ID: 21794562
thanks for your help. Seems like the pages cant find some SkinIDs. Thanks for helping me out with this.

Kamila.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question