Showing posts with label upload. Show all posts
Showing posts with label upload. Show all posts

Wednesday, March 28, 2012

Strange character transformations

Hi,

I have an ASP.Net website, which allows users to upload a file which is
then inserted into a database.

This is all fine until it reads a line with the string +Anu in it.
It transforms this to this char ? (which, if Googled for, is
described as Unicode Character 'LATIN SMALL LETTER TURNED R WITH HOOK'
(U+027B) or, in Phonetics, as a 'Retroflex approximant'.)

Has anyone seen this behaviour before, and know how to stop it?
The code's simple - here's an example. The ? appears in the output
where the input is +Anu - it's transformed before I can touch it!

using (StreamReader sr = new StreamReader(strFile,
System.Text.Encoding.UTF7)) {
// Read and display lines from the file until the end of the file is
reached.
while ((line = sr.ReadLine()) != null) {
Response.Write(line);
}
}

Regards

AdamLooks like an encoding issue, alright.
Have you tried using the StreamReader constructor that does not require a
character encoding?

"CyberSpyders@.gmail.com" wrote:

Quote:

Originally Posted by

Hi,
>
I have an ASP.Net website, which allows users to upload a file which is
then inserted into a database.
>
This is all fine until it reads a line with the string +Anu in it.
It transforms this to this char ? (which, if Googled for, is
described as Unicode Character 'LATIN SMALL LETTER TURNED R WITH HOOK'
(U+027B) or, in Phonetics, as a 'Retroflex approximant'.)
>
Has anyone seen this behaviour before, and know how to stop it?
The code's simple - here's an example. The ? appears in the output
where the input is +Anu - it's transformed before I can touch it!
>
using (StreamReader sr = new StreamReader(strFile,
System.Text.Encoding.UTF7)) {
// Read and display lines from the file until the end of the file is
reached.
while ((line = sr.ReadLine()) != null) {
Response.Write(line);
}
}
>
Regards
>
Adam
>
>


Graven,

I'm not sure how a 4 letter string like this could be seen as an
encoding issue, but I will certainly give it a go. Thanks for the
suggestion.

Adam

Graven wrote:

Quote:

Originally Posted by

Try to use plain latin-1 encoding. I think it's an unicode
normalization issue, but don't know if StreamReader performs it by
default.
>
>
CyberSpyders@.gmail.com wrote:

Quote:

Originally Posted by

Hi,

I have an ASP.Net website, which allows users to upload a file which is
then inserted into a database.

This is all fine until it reads a line with the string +Anu in it.
It transforms this to this char ? (which, if Googled for, is
described as Unicode Character 'LATIN SMALL LETTER TURNED R WITH HOOK'
(U+027B) or, in Phonetics, as a 'Retroflex approximant'.)

Has anyone seen this behaviour before, and know how to stop it?
The code's simple - here's an example. The ? appears in the output
where the input is +Anu - it's transformed before I can touch it!

using (StreamReader sr = new StreamReader(strFile,
System.Text.Encoding.UTF7)) {
// Read and display lines from the file until the end of the file is
reached.
while ((line = sr.ReadLine()) != null) {
Response.Write(line);
}
}

Regards

Adam


Larry,

You were spot on - changing to UTF8 stopped this transformation. Thanks

It's not quite solved my problem though.
The file is a Text file, each line being a series of files delimited by
the character, as this was unliekley to ever appear in the actual
data.

Unfortunately, UTF8 encoding strips these characters completely. ASCII
encoding, on the other hand, replaces them with ?

Oh the joy of character encoding.

Regards

Adam

Larry Lard wrote:

Quote:

Originally Posted by

This is why you are seeing what you are seeing. UTF7 encodes characters
outside the printable 7 bit range using UTF16 then modified base64, with
+ as the indicator mark for this encoding. I haven't checked, but I
imagine +Anu is the UTF7 encoding of that character. You shouldn't use a
UTF7 reader to read a file that you don't know for sure was produced by
a UTF7 writer.
>
The correct way to read the file depends on what kind of file it is. If
it is text of an unknown encoding, there is no way to be absolutely
sure, but UTF8 is a good starting point. If it's binary data, you
shouldn't be using a TextReader class at all.

Monday, March 26, 2012

Strange Error

I'm getting the following error on when I try to preview webpages from VWD2008. When I upload the pages I can view them fine from my website. Even more stange is it only happens on one certain project and it just started about 10 minutes ago as was fine until then. I have rebooted my computer but that did not help. When I go to view that directory, there are no files in it, nor can I unselect the read-only attribute to delete it.

Compilation Error

Description:An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message:BC30269: 'Public Sub New()' has multiple definitions with identical signatures.

Source Error:

[No relevant source lines]


Source File: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\mysite\1d37002e\e2be952b\App_Code.stpwyaqr.1.vb Line: 34

Can you show us the code behind for one of the pages that you are getting the error?


Weird on a couple of levels; your post does not display correctly to me, the text is all mashed onto a couple of lines. Fortunately the reply screen shows it ok.

I'm not sure I understand so see if this is correct. When you published the project to the web server it worked fine and the site published ok and is browsable. When you then tried to run the project in VWD to preview locally it gave the error you posted. When you went into the file system on your local machine the directory was blank.

Sound correct so far? If so, are you checking the project directory on your local machine or the temporary directory listed in the error message?


Did you try to do a Clean Project and a Rebuild Project? Are you using the Web Site project or Web Application project?


kraznodar:

I'm not sure I understand so see if this is correct. When you published the project to the web server it worked fine and the site published ok and is browsable. When you then tried to run the project in VWD to preview locally it gave the error you posted. When you went into the file system on your local machine the directory was blank.

Yes that is 100% correct. What is even more odd is the fact that I've been working on this same project for about 7 months, and until a while ago I never got this error. When I tried another project on my computer it ran with no errors. As for the page in question it is all the pages, not just one.

Ohhh, I just tried a rebuild like was suggested and got a bunch of errors relating to a dataset file. I deleted the file in question and now it works 100%

I had copied, then pasted a dataset and that must have corrupted something. I deleted it and no problems.

Guess the lesson is, don't copy/paste a dataset like you can a regular webpage file.

Thanks for the help and suggestions, I'm sure I'll have many more :)


Don't forget to mark noahb's post as the answer. His clean and rebuild led to the discovery of the real issue.

Saturday, March 24, 2012

Strange Errors

Im having a problem with one of my pages. Basically what i have is a page where someone can upload files and its all working ok. I also a have option for them to delete files, if they click this they are brought to a separate page to confirm the delete. It all works find for the first file i delete but when i try to do it again, my directory.delete function works but my database delete doesnt ? any idea's?Its ok figured it out, had the parameters in the wrong order !
Deleting a directory in asp.net is tricky. Afetr you delete a directorythe application will restart and u will looase all ur session dat if uare using in-proc session. Here is a link explaining that
http://vikramlakhotia.com/Post.aspx?postID=6

Thursday, March 22, 2012

strange file upload behaviour (404 with one pdf but not with another)

Hi

Maybe there is an oracle out there who can help.

I have an aspx site and a simple fileupload control on it.
Everything works fine except:
I can reproduce an 404 error when trying to upload some files.
It only happens when trying to upload PDF Files, and not on every PDF
File.

Let me illustrate this
xy.pdf - upload no problem
ab.pdf - 404 - Cannot find server or DNS Error

There are more pdf's where the problem occurs and also some others
where it does not..

The error comes within a millisecond as if IE does not try to upload.

What the heck is this...?i bet you the one that doesn't work is over 4 megs right?

mikecom@.gmx.net wrote:
> Hi
> Maybe there is an oracle out there who can help.
> I have an aspx site and a simple fileupload control on it.
> Everything works fine except:
> I can reproduce an 404 error when trying to upload some files.
> It only happens when trying to upload PDF Files, and not on every PDF
> File.
> Let me illustrate this
> xy.pdf - upload no problem
> ab.pdf - 404 - Cannot find server or DNS Error
> There are more pdf's where the problem occurs and also some others
> where it does not..
> The error comes within a millisecond as if IE does not try to upload.
> What the heck is this...?
max upload size in asp.net is 4 MB

you can change this in web.config:

<httpRuntime maxRequestLength="size in kbytes" /
asp.net uploads files into memory, so a 1 GB upload will take 1 GB of
memory on your server. if you want to upload big files, you'll need to
buy an upload component that streams uploaded files to disk.

mikecom@.gmx.net wrote:
> Hi
> Maybe there is an oracle out there who can help.
> I have an aspx site and a simple fileupload control on it.
> Everything works fine except:
> I can reproduce an 404 error when trying to upload some files.
> It only happens when trying to upload PDF Files, and not on every PDF
> File.
> Let me illustrate this
> xy.pdf - upload no problem
> ab.pdf - 404 - Cannot find server or DNS Error
> There are more pdf's where the problem occurs and also some others
> where it does not..
> The error comes within a millisecond as if IE does not try to upload.
> What the heck is this...?
Bet won!

That was the problem...

Tanks a lot!
neilmcguigan@.gmail.com wrote:
> max upload size in asp.net is 4 MB
> you can change this in web.config:
> <httpRuntime maxRequestLength="size in kbytes" />
> asp.net uploads files into memory, so a 1 GB upload will take 1 GB of
> memory on your server. if you want to upload big files, you'll need to
> buy an upload component that streams uploaded files to disk.
> mikecom@.gmx.net wrote:
> > Hi
> > Maybe there is an oracle out there who can help.
> > I have an aspx site and a simple fileupload control on it.
> > Everything works fine except:
> > I can reproduce an 404 error when trying to upload some files.
> > It only happens when trying to upload PDF Files, and not on every PDF
> > File.
> > Let me illustrate this
> > xy.pdf - upload no problem
> > ab.pdf - 404 - Cannot find server or DNS Error
> > There are more pdf's where the problem occurs and also some others
> > where it does not..
> > The error comes within a millisecond as if IE does not try to upload.
> > What the heck is this...?

strange file upload behaviour (404 with one pdf but not with another)

Hi
Maybe there is an oracle out there who can help.
I have an aspx site and a simple fileupload control on it.
Everything works fine except:
I can reproduce an 404 error when trying to upload some files.
It only happens when trying to upload PDF Files, and not on every PDF
File.
Let me illustrate this
xy.pdf - upload no problem
ab.pdf - 404 - Cannot find server or DNS Error
There are more pdf's where the problem occurs and also some others
where it does not..
The error comes within a millisecond as if IE does not try to upload.
What the heck is this...?i bet you the one that doesn't work is over 4 megs right?
mikecom@.gmx.net wrote:
> Hi
> Maybe there is an oracle out there who can help.
> I have an aspx site and a simple fileupload control on it.
> Everything works fine except:
> I can reproduce an 404 error when trying to upload some files.
> It only happens when trying to upload PDF Files, and not on every PDF
> File.
> Let me illustrate this
> xy.pdf - upload no problem
> ab.pdf - 404 - Cannot find server or DNS Error
> There are more pdf's where the problem occurs and also some others
> where it does not..
> The error comes within a millisecond as if IE does not try to upload.
> What the heck is this...?
max upload size in asp.net is 4 MB
you can change this in web.config:
<httpRuntime maxRequestLength="size in kbytes" />
asp.net uploads files into memory, so a 1 GB upload will take 1 GB of
memory on your server. if you want to upload big files, you'll need to
buy an upload component that streams uploaded files to disk.
mikecom@.gmx.net wrote:
> Hi
> Maybe there is an oracle out there who can help.
> I have an aspx site and a simple fileupload control on it.
> Everything works fine except:
> I can reproduce an 404 error when trying to upload some files.
> It only happens when trying to upload PDF Files, and not on every PDF
> File.
> Let me illustrate this
> xy.pdf - upload no problem
> ab.pdf - 404 - Cannot find server or DNS Error
> There are more pdf's where the problem occurs and also some others
> where it does not..
> The error comes within a millisecond as if IE does not try to upload.
> What the heck is this...?
Bet won!
That was the problem...
Tanks a lot!
neilmcguigan@.gmail.com wrote:
> max upload size in asp.net is 4 MB
> you can change this in web.config:
> <httpRuntime maxRequestLength="size in kbytes" />
> asp.net uploads files into memory, so a 1 GB upload will take 1 GB of
> memory on your server. if you want to upload big files, you'll need to
> buy an upload component that streams uploaded files to disk.
> mikecom@.gmx.net wrote: