I have two APS .NET applications running on the same server.
Both applications create folders and upload files inside the same virtual folder (they both use the same code - see below).
The first application doesn't request authentication to log in and it is available for anybody outside (no NT Authentication). This application works perfect.
The second application requests windows authentication (internal use only). When i run this application from my localhost it allows me to upload files without problem but when I deploy the application on the server and acces it through the web (intranet) it gives me the following error when trying to upload:
Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED)-
Error String:System.Security.SecurityException:
Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED)
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall
(Object o, Type objType, String name, Object[] args,
String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall
(Object Instance, Type Type, String MemberName, Object[] Arguments,
String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack,
Boolean IgnoreReturn) at logConversation.FilesUpload()
The Zone of the assembly that failed was: MyComputer
Both folders/permissions/applications have the same setting/permissions.
I tried changing the trust levet to "Full" on my webconfig file but didn't work.
Any help will be appreciated.
--------------------------------------------------------
Code
Sub FilesUpload()
Dim strPath As String = "\\virtualServ\folderName\"
Dim uploads As HttpFileCollection = HttpContext.Current.Request.Files
Dim upload As HttpPostedFile
Dim objFSO As Object = Server.CreateObject("Scripting.FileSystemObject")
If uploads.Count >= 1 Then
Dim i As Integer = 0
Do While i <> uploads.Count
upload = uploads(i)
If (upload.ContentLength <> 0) Then
If Not objFSO.FolderExists(strPath & (Replace(strUserEmail, " ", "_"))) Then
objFSO.CreateFolder(strPath & (Replace(strUserEmail, " ", "_")))
end if
strFileName = System.IO.Path.GetFileName(upload.FileName)
upload.SaveAs(strPath & (Replace(strUserEmail, " ", "_")) & "\" & strFileName)
End If
i = i + 1
Loop
End If
End sub
Both applications create folders and upload files inside the same virtual folder (they both use the same code - see below).
The first application doesn't request authentication to log in and it is available for anybody outside (no NT Authentication). This application works perfect.
The second application requests windows authentication (internal use only). When i run this application from my localhost it allows me to upload files without problem but when I deploy the application on the server and acces it through the web (intranet) it gives me the following error when trying to upload:
Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED)-
Error String:System.Security.SecurityException:
Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED)
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall
(Object o, Type objType, String name, Object[] args,
String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall
(Object Instance, Type Type, String MemberName, Object[] Arguments,
String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack,
Boolean IgnoreReturn) at logConversation.FilesUpload()
The Zone of the assembly that failed was: MyComputer
Both folders/permissions/applications have the same setting/permissions.
I tried changing the trust levet to "Full" on my webconfig file but didn't work.
Any help will be appreciated.
--------------------------------------------------------
Code
Sub FilesUpload()
Dim strPath As String = "\\virtualServ\folderName\"
Dim uploads As HttpFileCollection = HttpContext.Current.Request.Files
Dim upload As HttpPostedFile
Dim objFSO As Object = Server.CreateObject("Scripting.FileSystemObject")
If uploads.Count >= 1 Then
Dim i As Integer = 0
Do While i <> uploads.Count
upload = uploads(i)
If (upload.ContentLength <> 0) Then
If Not objFSO.FolderExists(strPath & (Replace(strUserEmail, " ", "_"))) Then
objFSO.CreateFolder(strPath & (Replace(strUserEmail, " ", "_")))
end if
strFileName = System.IO.Path.GetFileName(upload.FileName)
upload.SaveAs(strPath & (Replace(strUserEmail, " ", "_")) & "\" & strFileName)
End If
i = i + 1
Loop
End If
End sub