File Upload using ASP.NET in Medium Trust

unicode

Guppy
Has anyone been able to successfully deploy file upload in medium trust config. It would be really nice - if they could upload a sample code file / config or instructions on going about doing the same ...

Code - in ASP.NET (c#) - would be really helpful ! ... Image upload is a generic feature of any dynamic site ... and it would be really nice if someone has done it and can help with the same ...
 
Mojoportal does asp.net uploads in medium trust really well, I haven't done a code breakdown but it works every time :D
 
Yeah Stephen ...

Dun know - am unable to replicate the same in our program ...

Am wondering - if someone has used a file upload in medium trust - and can post the code snippet - would be really super helpful ! ...
 
I found an AJAX upload tool that works in medium trust:
http://ajaxuploader.com/FAQ.htm#18

the main issue is to ensure you are using relative paths and not hard coded paths, or physical paths, if you use a physical path or a mappath that reads like d:\hshome\user\domain\folder\foldertoupload, it is 100% going to fail every time.

Here is a more complete example using a flash based uploader with asp.net backend designed for medium trust level.
http://www.codeproject.com/KB/aspnet/FlashUpload.aspx
 
I have several asp.net sites that all upload using the standard methods.

What errors are you getting? I think you need support to make the upload directory writeable as well.

Cheers,

Paul.
 
What errors are you getting? I think you need support to make the upload directory writeable as well.

Cheers,

Paul.
We've done that, it is system permissions errors, about trust level not able to access d:\, so it isn't using the virtual path.
 
Yeah ... even after putting the paths rights - we get the exception.

I am sure someone is using File Upload in a Medium Trust - if anyone can help - will be awesome !

Below is a copy paste of the error ...

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 failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[SecurityException: Request failed.]
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) +150
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) +100
System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) +284
System.Security.PermissionSetTriple.CheckSetDemand(PermissionSet demandSet, PermissionSet& alteredDemandset, RuntimeMethodHandle rmh) +69
System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandle rmh) +150
System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet) +30
System.Threading.CompressedStack.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet) +40
System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant, CompressedStack securityContext) +123
System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant) +54
 
I have several asp.net sites that all upload using the standard methods.

What errors are you getting? I think you need support to make the upload directory writeable as well.

Cheers,

Paul.

Can u put up a sample code please - a simple stuff which works - which we can try and use - in asp.net c# medium trust environment ...

We've tried almost everything ... we could find on the net ! ...

Most sites needs basic image upload functionality - and we are getting stuck in there ....

Help will be highly appreciated :)

Thanx.
 
Back
Top