Uploading Large Files (tab delimited) on to C# Server

I get the WSOD (White Screen of Death - blank internet page) when I try to upload a large file to my web server from my local file system. It works perfectly fine with small files, but not with large ones.
I can select a file and when I hit "Click to Upload to SQL Server" (see code below) -- if the file is small -- it works fine. If it's large -- 25Megs is the general file size I am attempting to upload, I get a WSOD (blank internet page).

The ultimate goal is to upload the file into SQL Server which I do via a stored proc from my C# code. that allows me to do a bulk copy to SQL Server (which works fine) ... it's just the file size that is causing me trouble. If there is a better way to solve this (ultimately, I am attempting to upload a .tab file into SQL Server.) The fields in the tabbed file never change, so I am creating a new table with the current date based a template table and populating it.

Thanks in advance.
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPageReports.master" AutoEventWireup="true" CodeFile="GEM_EQ4_Bulk_File_Comparison.aspx.cs" Inherits="Reports_GEM_EQ4_Bulk_File_Comparison" %>

<asp:Content ID="Content1" ContentPlaceHolderID="header" Runat="Server">
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="sidebar" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="content" Runat="Server">
<asp:FileUpload ID="fileUploadBulk" runat="server" />
<asp:Button ID="btnCopyToServer"  runat="server" Text="Click to Upload to SQL Server"  OnClick="copyToGemShare" /> 
<asp:label ID="lblStatus" runat="server"></asp:label>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="rightbar" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer" Runat="Server">
</asp:Content>

------------ .aspx code


<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPageReports.master" AutoEventWireup="true" CodeFile="GEM_EQ4_Bulk_File_Comparison.aspx.cs" Inherits="Reports_GEM_EQ4_Bulk_File_Comparison" %>

<asp:Content ID="Content1" ContentPlaceHolderID="header" Runat="Server">
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="sidebar" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="content" Runat="Server">
<asp:FileUpload ID="fileUploadBulk" runat="server" />
<asp:Button ID="btnCopyToServer"  runat="server" Text="Click to Upload to SQL Server"  OnClick="copyToGemShare" /> 
<asp:label ID="lblStatus" runat="server"></asp:label>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="rightbar" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer" Runat="Server">
</asp:Content>


//////////////////////////////////////////
//CODE BEHIND
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;

public partial class Reports_GEM_EQ4_Bulk_File_Comparison :  NGB.ARQ.SECURITY.CACAuthentication.PersistViewStateToFileSystem
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void copyToGemShare(object sender, EventArgs e)
    {
         if (fileUploadBulk.HasFile)
        {

            string filepath = fileUploadBulk.PostedFile.FileName;
            string pat = @"\\(?:.+)\\(.+)\.(.+)";
            Regex r = new Regex(pat);
            //run
            Match m = r.Match(filepath);
            string file_ext = m.Groups[2].Captures[0].ToString();
            string filename = m.Groups[1].Captures[0].ToString();
            string file = filename + "." + file_ext;

            //save the file to the server 
            fileUploadBulk.PostedFile.SaveAs(Server.MapPath(".\\GemShare\\") + file);
            lblStatus.Text = "File Saved to: " + Server.MapPath(".\\GemShare\\") + file;

        }
    } 
}

Open in new window

LVL 1
jvantassel1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

masterpassCommented:
The default max size for upload in .NET is 4MB. try changing this in web.config

<system.web>
<httpRuntime executionTimeout="240" maxRequestLength="20480" /> (value is in KB, change accordingly)
</system.web>

suggested reading : http://weblogs.asp.net/jgalloway/archive/2008/01/08/large-file-uploads-in-asp-net.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jvantassel1Author Commented:
Excellent Solution  - Exactly what was needed, very easy to implement. Thank you very much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.