Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Request.TotalBytes
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Zuel
Average Member

USA
540 Posts

Posted - 02 July 2007 :  15:09:08  Show Profile  Visit Zuel's Homepage
While posting a cry for help, I thought of and created a solution. Figured I would post it anyways since it works flawlessly. Maybe you know a better way.

Well I created an upload script and before the looping and swifting through data I wanted to ensure the filesize was legit before making the server work.

Everytime I grabbed the Filesize by getting the Request.TotalBytes, I would get http bad requests after a few attempts to upload a huge file to test the validation. I tried everything to get rid of the 500 errors but I had no luck.

The problem is the server is posting data over and nothing is catching it. When the file size was invalid I never read the bytes passed over. So what did I do? I read it anyways.

Dim FileSize : FileSize = Request.TotalBytes

Select Case (IsValidSize(CLng(FileSize)))
  Case True:  '=== More Validation ===
  Case Else:  SetErrorMessage()
End Select

Select Case (IsEmpty(m_ErrorMessage))
  Case True:  UploadFile(Request.BinaryRead(FileSize))
  Case Else:  Dim PlaceHolder : PlaceHolder = Request.BinaryRead(FileSize) : PlaceHolder = Null
      SetIsSaved = False
End Select


Reading it and disposing of it clears all those bad requests away. Yay!

File reads are instantaneous and now the script rejects over sized files immediately rather then reading the file for several seconds then rejecting.

My Completed Mods: News Mod | Zuel's Avatar Add-on
In Development: World of Warcraft Member Roster | [C# Based Forum]

Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.

MSN / E-Mail: ucyimDa_Ruler@Hotmail.com

Personal Bookmarks: How to work a DBS File

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 02 July 2007 :  16:34:09  Show Profile  Visit HuwR's Homepage
you do realise that you have still uploaded the file though, request.TotalBytes tells you how much data HAS been sent in the request, there is no way to check this value prior to an upload.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.22 seconds. Powered By: Snitz Forums 2000 Version 3.4.07