Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 969413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:38:10+00:00 2026-05-16T02:38:10+00:00

We have a very simple ASP.Net page for uploading a file to our webserver.

  • 0

We have a very simple ASP.Net page for uploading a file to our webserver. The page has no controls – a client uses it to automatically send us a file each night.

On occasion, the file seems to not get to us, but the client reports that they have sent it.

We added some logging statements to the page, and discovered something quite odd. The page ceases to execute right in the middle of a log statement. No exceptions, just up and dies.

Here is the code-behind:

protected void Page_Load(object sender, EventArgs e) {
    try {
        // record that request came in at all
        log.Debug("Update Inventory page requested through HTTP {2} on {0} {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString(), IsPostBack ? "POST" : "GET");

        // make sure directory exists
        string basePath = Server.MapPath("~/admin/uploads/");
        log.Debug("Saving to folder {0}", basePath);

        if (!Directory.Exists(basePath)) {
            log.Debug("Creating folder {0}", basePath);
            Directory.CreateDirectory(basePath);
        }

    // generate a unique file name
        string fileName = DateTime.Now.Ticks.ToString() + ".dat";
        string path = basePath + fileName;
        log.Debug("Filename to save is {0}", fileName);

    // record initial bytes of stream/file
    StreamReader reader = new StreamReader(stream);
    string fileContents = reader.ReadToEnd();

    log.Debug("File received by GET is " + fileContents.Length + " characters long and begins with: " 
        + Environment.NewLine + fileContents.Substring(0, Math.Min(fileContents.Length, 1000)));

    // write out file
    File.WriteAllText(path, fileContents);

        log.Debug("Update Inventory page processing finished.");
        // trap for and record any and all exceptions
    } 
    catch (Exception ex) {
        log.Debug(ex);
    }
}

The processing seems to die in the middle of the log statement that outputs the length and first portion of the fileContents variable. The logging that occurs when the process fails looks like this:

2010-08-02 02:46:01.7342|DEBUG|UpdateInventory|Update Inventory page requested through HTTP GET on 8/2/2010 2:46:01 AM
2010-08-02 02:46:01.7655|DEBUG|UpdateInventory|Saving to folder c:\hosting\sites\musicgoround.com\wwwroot\admin\uploads\
2010-08-02 02:46:01.7811|DEBUG|UpdateInventory|Filename to save is 634163139617811250.dat
2010-08-02 02:48:02.3905|DEBUG|UpdateInventory|

I really don’t understand what to make of this.

I assume if there was a error in the transmission of the file that either an exception would be thrown from the reader.ReadToEnd() line. And if not an exception, I would expect the page processing to continue but that I may only receive part of the file (in which case it should log something).

The logging statement is only accessing a string variable, and it’s inside a try-catch. NLog is the logging component we use, and we access that through the facade provided by the Simple Logging Facade project on Codeplex. So, we trust the logging component to be more or less bulletproof – we certainly don’t see anything in our usage of it here that should be causing problems.

So, what’s the deal? Why on earth could this page just up and stop processing like this?

The fact that we get a half-finished logging statement seems to point towards an error being swallowed in the logging system – but that just seems so unlikely – and we have NLog’s internal logging on and it is not reporting any problems.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:38:11+00:00Added an answer on May 16, 2026 at 2:38 am

    The most likely candidate is that this line:

    2010-08-02 02:48:02.3905|DEBUG|UpdateInventory|
    

    Is caused by this:

    log.Debug(ex);
    

    I.e. it is throwing an exception, but the logger is not recording anything useful. Why don’t you try switching about the log levels a bit, e.g. change the exception logging level to error:

    log.Error(ex);
    

    That way you can see if it is actually throwing an exception and it is just the logger not recording the exception string properly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple page built in asp.net (.NET Framework 4) which has
I have a very simple ASP.Net page that acts as a front end for
I have an ASP.Net MVC Page with a very simple form on it: One
This really should be so very simple... I have an asp.net master page which
We have a very simple ASP.NET web application comprising mostly static content and a
I have a very simple application which consists of an ASP.NET front end site,
I have a simple ASP.NET page where after the initial page load the user
I am very new to ASP.NET. I have a an ASP.NET page with an
I have a very simple ASP.Net MVC Application that I have produced from an
Background: I'm creating a very simple chatroom-like ASP.NET page with C# Code-Behind. The current

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.