Computing.Net > Forums > Web Development > File Upload Control (ASP.NET)

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

File Upload Control (ASP.NET)

Reply to Message Icon

Name: srenvas
Date: July 27, 2007 at 01:07:57 Pacific
OS: Windows 2003 Server
CPU/Ram: 1 GB
Product: DELL
Comment:

I am facing some problem with file upload control in asp.net 2.0..while uploading a file onto the server.this is all working fine on the local development machine.but giving problem on the web server after deployment..the error goes something like this..
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. [ Security Exception ]

All the write permissions are given to the folders on web server..

If any one has idea on how to chase it please

Thanks
Srenvas



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 29, 2007 at 19:00:26 Pacific
Reply:

1) Check to make sure both the IIS and ASP accounts have create file access to the directories in question.

2) Check to make sure the paths are valid for the production machine.

3) Check the production server's configuration for the app, and make sure the server allows file uploads. I'd give you more specific answer for this step, but I'm not near a machine with IIS installed.


0

Response Number 2
Name: srenvas
Date: July 29, 2007 at 21:42:28 Pacific
Reply:

Thnks Razor2.3

1 ) the root directory has full access for write permission.
2 ) the paths are correct as i am using ~/ for accessing the folder
3 ) This is where i am not able to get the point. How do i know whether the production server would allow file upload or not. bcoz the exception is as follows and is clear that its not getting the permissions and i hve written the issue to the production server support team and they say we cant help in this regard :-( dnt know wht to do

Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:


Line 32: End If
Line 33:
Line 34: Dim fi As New IO.FileInfo(fuImage.PostedFile.FileName)
Line 35: objServices.ServiceImage = fi.Extension
Line 36: Dim PhotoId As Integer = objServicesBO.InsertMrservices(objServices)

Source File: d:\hosting\imrshop\projects\mrcentre\Admin\ManageServices.aspx.vb Line: 34

From this can you pls make out anything and tell me wht is the bug or the problem with the server. I feel that the permissions for hte domain are managed by the machine levle config file ? am i right

Thanks
Srenvas


0

Response Number 3
Name: Razor2.3
Date: July 29, 2007 at 22:14:31 Pacific
Reply:

~/ is a *NIX standard and not a Windows standard, so you can't use it [reliably].

To get the current directory, you could try .\, but I've had limited success with it. The best bet would be to use the full Windows path.

.NET will tell you the executing directory; it's somewhere in System.Reflection.

A quick MSDN search turned up this bit of code:
Dim path As String
path = System.IO.Path.GetDirectoryName( _
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)


0

Response Number 4
Name: srenvas
Date: July 29, 2007 at 22:22:32 Pacific
Reply:

ok i have used ur method of mapping the file path , still does not work. now the question is how to manage to know if the server is allowing upload of files from my application.


Thanks
Srenvas


0

Response Number 5
Name: Razor2.3
Date: July 30, 2007 at 03:25:06 Pacific
Reply:

Okay, found a reference to the config changes I was talking about in Reply 1.

webdesign.ittoolbox.com


0

Related Posts

See More



Response Number 6
Name: srenvas
Date: July 30, 2007 at 05:35:57 Pacific
Reply:

Thnks for that , ok for this i think i need access to the webserver directly ,but my server is an hosting company and i host my application using ftp and config it on the control panel, the solution which you have provided should solve the problem i think , but i dnt have access to the webserver i have talked to the support team and they said they cant allow me access to the server :-( i am in trouble again..soory can u help me in any other way anything where i can change my application level config file and make the thing work

Thnks


Thanks
Srenvas


0

Response Number 7
Name: Razor2.3
Date: July 31, 2007 at 20:11:46 Pacific
Reply:

Well, you should be able to see if a file does upload; it's crashing after you issued a fuImage.PostedFile.SaveAs(String), so it's just a matter of FTP'ing into the server, and see if anything's there. If not, you can just issue one for debug purposes.

It looks like it's crashing because it can't get the (potential) file permissions, which could be caused by security being set too high, or security being set reasonably (for ASP), and the path being malformed.

If you're creating an IO.FileInfo just to grab the extension, there are easier ways to do it. Personally, I like:
int iExt = fuImage.Value.LastIndexOf(".") + 1
If iExt Then
objServices.ServiceImage = fuImage.Value.Substring(iExt)
...


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: File Upload Control (ASP.NET)

ASP.net DataGrid Display!!! Help! www.computing.net/answers/webdevel/aspnet-datagrid-display-help/1584.html

Server Controls Array in ASP.NET www.computing.net/answers/webdevel/server-controls-array-in-aspnet/3402.html

how to get full file path ???? www.computing.net/answers/webdevel/how-to-get-full-file-path-/4052.html