|
Hello, I'm working on an internal e-mail utility to send messages to different groups from a database. One feature i'm implementing is the ability to add e-mail attachments. I have every thing working the way it should but it seems if a user tries to attach an Exe file, the page breaks.
for instance, if you had the file "breakit.exe" and tried to attach it, it would give me a "page cannot be displayed error" after I hit the "upload" button. if you try this with a .jpg, .txt, or anything it works, but the page breaks even if I try to change the name of "breakit.exe" to "breakit.notanexe".
Does any one know how to detect this problem before the page breaks?
thanks,
-Ian.M
if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
{
string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
string SaveLocation = Server.MapPath("Data\\" + ParentSessionID.Value);
if (!System.IO.Directory.Exists(SaveLocation))
{
System.IO.Directory.CreateDirectory(SaveLocation);
}
try
{
File1.PostedFile.SaveAs(SaveLocation + "\\" + fn);
}
catch (Exception ex)
{
}
}
|
|
|
|
|
What do you mean by "the page breaks"? Where is the code sample you provided being run? Is this part of the code that handles the upload button?
If you don't want to allow executable files at all, you could probably use the System.IO.Path.GetExtension method to get the file extension. If the extension is ".exe", don't upload the file. Of course, this doesn't really prevent someone from uploading an executable, it just prevents them from using certain extensions.
|
|
|
|
|
Torin_DWC wrote: "page cannot be displayed error" after I hit the "upload" button
Have you tried setting a breakpoint and stepping threough to determine what the real error is? Its just that "Page cannot be displayed" is the generic error that is shown in the browser and provides no information for somebody trying to help you with this issue.
|
|
|
|
|
ya i got VS2005 here and I'm in debug mode but it's not stopping anywhere, I have break points at the top of Submit1_ServerClick which is what the upload button calls when it is pressed. This issue is only happening on exe files and exe files that have been renamed to other extentions. I'm guessing that something is looking at the file properties or file headers?
The strange thing is that it happens with all exe's, but not all exe's that have had their file extention changed.
so like:
iata76_enu.exe breaks page
iata76_enu.cheese breaks page
Silverlight.1.0.exe uploads fine
Silverlight.1.0.cheese uploads fine
NOTEPAD.EXE uploads fine
NOTEPAD.CHEESE uploads fine
Only reason I have that iata76_enu.exe is cause I was helping my coworker, otherwise I would never have run into this issue while testing the page.
-Ian.M
|
|
|
|
|
Ah then its obvious...nothing to do with exe and everything to do with filesize.
I'm willing to bet that iata76_enu.exe is substantially larger in filesize than notepad.exe
|
|
|
|
|
we have a winner, the thing dies if you try to upload a file greater than 5mb, but the strange thing is that this is not caught by the VS2005 debugger. I'll fiddle with it and see if I can check the file size once the openfile dialog is closed and before the user hit's the upload button :P
thanks again guys
-Ian.M
|
|
|
|
|
Hi Guys
Need help urgently. I am creating An Excel File Report Format. Data are read from SQLReader and insert into excel reports. However When i Generate the report the first time. It Can be successfully Generate but when i press the button to regenerate the report again it hit this error E_OUTOFMEMORY(0*8007000E)
Guys Please advise! Any method or solution
I am using asp.net 2.0 with ajax extension 1.0
KaKaShi HaTaKe
|
|
|
|
|
Did you configure ISS to use more memory?
|
|
|
|
|
May i know where to configure the memory as i am using ISS 6.0 and framework 2.0
KaKaShi HaTaKe
|
|
|
|
|
Control Panel->Administration Tools->Internet System Server (Not sure if i typed correctly)
And search for setting, I don't have iss currently installed, so i don't know where exactly
|
|
|
|
|
R/s sir,
i want to do something like...... there is two pages first page has a button and i want to use click event method of this button in another page. so what can i do it, it is possible or not. this is very argent.
i will be heighly oblise u
thanks in advance
yogesh
|
|
|
|
|
Please Check Ur Last Post
I have already post ur ans ,
|
|
|
|
|
|
If I use the external utility to encrypt the connection string in web.config, will .net automatically know how to decrypt it when I build table adapters and such?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
No
You will have to programaticly decrypt connection string before opening database.
Why do you want to encrypt it?
If ISS is normaly configured, you cant get Web.config.
PS: You cant decrypt one way encriptions (Hash) like md5.
|
|
|
|
|
Saksida Bojan wrote: Why do you want to encrypt it?
My boss wants it encrypted.
Saksida Bojan wrote: If ISS is normaly configured, you cant get Web.config.
What does that mean?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: What does that mean?
It means that unothorized persons can't get web.config via browsers.
John Simmons / outlaw programmer wrote: My boss wants it encrypted.
If so, then stay away from one way encryptions.
|
|
|
|
|
Saksida Bojan wrote: It means that unothorized persons can't get web.config via browsers.
Evidently, that doesn't matter if IIS can be hacked and a remote user can gain access to the server.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
i have already created help file using robohelp and set map ID for each topic. So different id's and .htm files are there. I want to open the help file to the corresponding topic for each aspx page, when I press F1 key. But I don't know how to connect the map id through my web page. I tried with 'onHelp' event in script. But it only opens the help file, not the corresponding topic. Is using 'onHelp' in , the right way? Or any other better way is there to trap the F1 key? Please explain what are the steps for the corresponding problem.please give information for the corresponding problem.
hashim
|
|
|
|
|
R/s sir,
i have two pages default1.aspx and default2.aspx. there is a button in default1 page, i want to control transfer to another page, like when i click this butoon then some value has to changed in another page.
thanks in advance.................
yogesh
|
|
|
|
|
Hi Yogesh,
Sending Value and Sending Control is Total Diiferent Things.
yogesh_softworld123 wrote: i want to control transfer to another page,
If This is your Query can explain in details
yogesh_softworld123 wrote: when i click this butoon then some value has to changed in another page.
And if This is your query , u can easily do it using Session or Query String
e.g
private void Button1_Click()
{
Session["Myvalue"]=TextBox1.Text;
Response.Redirect("Default2.aspx");
}
and in Default2.aspx
Form_load()
{
Textbox2.Text=Session["MyValue"].ToString();
}
-------------
Did u get your answer ???? Then Vote it.
Happy Programming
-----------------
Abhijit Jana
Noida, India
|
|
|
|
|
R/s sir,
i want to do something like...... there is two pages first page has a button and i want to use click event method of this button in another page. so what can i do it, it is possible or not. this is very argent.
i will be heighly oblise u
thanks in advance
yogesh
yogesh
|
|
|
|
|
|
That is impossible to achive, because you dont have direct accses to diffrent page like application.
One way to achive this is to use session, and somehow you triger to refresh that page, and if session is there then trigger that event.
Also you coud use class, and that trigger woud be in static class, first page and second page woud refer to that function.
I can say one thing.
If there is a way to avoid such programing, Don't think the second time.
|
|
|
|
|
write this code on page load event
ButtonName.PostBackUrl = "default.aspx?value1=" & value1 & "&&" & "value2=" & value2 & "
Thanks
Sarfarj Ahmed
|
|
|
|