I am using ClubStarter Kit with goDaddy and recently came across a new error when uploading an image to a gallery. In the past the process worked fine, but recently it has stopped working and throws an error. GoDaddy may changed something on their server
to stop the write to the database. Can someone please help me with this new error?
Here it is:
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.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
Line 57: newThumb.Close() Line 58: Line 59: Image.Insert(title, filename, albumid, "") Line 60: Line 61: Dim newimg As New Image(Image.Columns.ImageFileName, filename)
If you haven't changed anything in your application configuration file regarding application's trust level AS IT SAYS IN THE SECURITY EXCEPTION, you will definitely need to contact the hosting provider (GoDaddy) and explain your problem in details so that
they will inform you with accurate info about what did they changed or any other info from their side.
Maybe someone else have had similar experience and may give you more accurate answer, but still I think you will have to contact your hosting company for this issue.
Cheers,
Hajan
Best Regards,
Hajan
Dont forget to Mark as Answer the answer that solved your problem!
Hi Bruce, thanks for the feedback. I spoke with GoDaddy and the rep said that in ASP.Net 1.1 the full trust level is available. Of course using older languauge limits what the app can and can't do.
The piece of code in question is this (line 38 is throwing the error):
Public Shared Function uploadImage(ByVal title As String, ByVal albumid As Integer, ByVal data As IO.Stream, Optional ByVal path As String = "") As Integer
Dim origImageData(CInt(data.Length - 1)) As Byte
data.Read(origImageData, 0, CInt(data.Length))
Dim imgStore As ImageLocation = GetLocation()
If imgStore = ImageLocation.Database Then
Images.Insert(title, MakeThumb(origImageData, 350), MakeThumb(origImageData, 69, 69), origImageData, albumid, "")
Dim imgs As New Images(Images.Columns.Origimage, origImageData)
If imgs.IsLoaded = True Then
Return imgs.Id
Else
Return 0
End If
ElseIf imgStore = ImageLocation.FileSystem Then
If Not Directory.Exists(path) Then
Directory.CreateDirectory(path)
End If
Dim filename As String = Now.Year & Now.DayOfYear & Now.Hour & Now.Minute & Now.Second & Now.Millisecond & ".jpg"
Dim thumbLargeImage As Byte() = MakeThumb(origImageData, 350)
Dim thumbSmallImage As Byte() = MakeThumb(origImageData, 69, 69)
Dim newImageFile As FileStream = New FileStream(path & filename, FileMode.Create)
newImageFile.Write(origImageData, 0, origImageData.Length)
newImageFile.Close()
Dim newThumbFile As New FileStream(path & "large" & filename, FileMode.Create)
newThumbFile.Write(thumbLargeImage, 0, thumbLargeImage.Length)
newThumbFile.Close()
Dim newThumb As New FileStream(path & "tmb" & filename, FileMode.Create)
newThumb.Write(thumbSmallImage, 0, thumbSmallImage.Length)
newThumb.Close()
Image.Insert(title, filename, albumid, "")
Dim newimg As New Image(Image.Columns.ImageFileName, filename)
If newimg.IsLoaded = True Then
Return newimg.Id
Else
Return 0
End If
End If
End Function
Is there another way of inserting this into data into the database? This is the last peice of the puzzle. I'm sure this insertion was working back in August 2009 when I first launched the site. Seems to me goDaddy made some changes and broke the darn thing.
Also, what other hosting companies offer .net FULL Trust as part of their hosting? I need to get out of the GoDaddy realm if this is going to continue to happen.
Jes.. only 1.1 offers full trust.. in case you don't realized, asp.net 4.0 was released today. Going back to 1.1 is like going back 2 generations.
dude9er
Is there another way of inserting this into data into the database?
I think your code already has the ability to insert the image into the DB.
# If imgStore = ImageLocation.Database Then
# Images.Insert(title, MakeThumb(origImageData, 350), MakeThumb(origImageData, 69, 69), origImageData, albumid, "")
#
# Dim imgs As New Images(Images.Columns.Origimage, origImageData)
# If imgs.IsLoaded = True Then
# Return imgs.Id
# Else
# Return 0
# End If
dude9er
Also, what other hosting companies offer .net FULL Trust as part of their hosting?
You can check out our hosting service. http://www.discountasp.net
dude9er
Member
49 Points
176 Posts
GoDaddy Upload Image to Gallery Error (NEW)
Apr 10, 2010 06:20 PM|LINK
I am using ClubStarter Kit with goDaddy and recently came across a new error when uploading an image to a gallery. In the past the process worked fine, but recently it has stopped working and throws an error. GoDaddy may changed something on their server to stop the write to the database. Can someone please help me with this new error?
Here it is:
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.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
Source File: D:\Hosting\5833289\html\App_Code\BLL\ImageHandling.vb Line: 59
THANKS!!!!!
hajan
Star
10655 Points
1782 Posts
Re: GoDaddy Upload Image to Gallery Error (NEW)
Apr 11, 2010 01:56 AM|LINK
Hi there.
If you haven't changed anything in your application configuration file regarding application's trust level AS IT SAYS IN THE SECURITY EXCEPTION, you will definitely need to contact the hosting provider (GoDaddy) and explain your problem in details so that they will inform you with accurate info about what did they changed or any other info from their side.
Maybe someone else have had similar experience and may give you more accurate answer, but still I think you will have to contact your hosting company for this issue.
Cheers,
Hajan
Hajan
Dont forget to Mark as Answer the answer that solved your problem!
My ASP.NET Weblog
Bruce L
All-Star
18102 Points
2841 Posts
Re: GoDaddy Upload Image to Gallery Error (NEW)
Apr 12, 2010 07:20 PM|LINK
This error indicate your application is trying to write to the file system outside of your virtual directory which is prohibited under Medium Trust.
I don't believe goDaddy allows you to elavate the trust level.
http://www.discountASP.NET
dude9er
Member
49 Points
176 Posts
Re: GoDaddy Upload Image to Gallery Error (NEW)
Apr 12, 2010 07:33 PM|LINK
Hi Bruce, thanks for the feedback. I spoke with GoDaddy and the rep said that in ASP.Net 1.1 the full trust level is available. Of course using older languauge limits what the app can and can't do.
The piece of code in question is this (line 38 is throwing the error):
Public Shared Function uploadImage(ByVal title As String, ByVal albumid As Integer, ByVal data As IO.Stream, Optional ByVal path As String = "") As Integer Dim origImageData(CInt(data.Length - 1)) As Byte data.Read(origImageData, 0, CInt(data.Length)) Dim imgStore As ImageLocation = GetLocation() If imgStore = ImageLocation.Database Then Images.Insert(title, MakeThumb(origImageData, 350), MakeThumb(origImageData, 69, 69), origImageData, albumid, "") Dim imgs As New Images(Images.Columns.Origimage, origImageData) If imgs.IsLoaded = True Then Return imgs.Id Else Return 0 End If ElseIf imgStore = ImageLocation.FileSystem Then If Not Directory.Exists(path) Then Directory.CreateDirectory(path) End If Dim filename As String = Now.Year & Now.DayOfYear & Now.Hour & Now.Minute & Now.Second & Now.Millisecond & ".jpg" Dim thumbLargeImage As Byte() = MakeThumb(origImageData, 350) Dim thumbSmallImage As Byte() = MakeThumb(origImageData, 69, 69) Dim newImageFile As FileStream = New FileStream(path & filename, FileMode.Create) newImageFile.Write(origImageData, 0, origImageData.Length) newImageFile.Close() Dim newThumbFile As New FileStream(path & "large" & filename, FileMode.Create) newThumbFile.Write(thumbLargeImage, 0, thumbLargeImage.Length) newThumbFile.Close() Dim newThumb As New FileStream(path & "tmb" & filename, FileMode.Create) newThumb.Write(thumbSmallImage, 0, thumbSmallImage.Length) newThumb.Close() Image.Insert(title, filename, albumid, "") Dim newimg As New Image(Image.Columns.ImageFileName, filename) If newimg.IsLoaded = True Then Return newimg.Id Else Return 0 End If End If End FunctionIs there another way of inserting this into data into the database? This is the last peice of the puzzle. I'm sure this insertion was working back in August 2009 when I first launched the site. Seems to me goDaddy made some changes and broke the darn thing.
Also, what other hosting companies offer .net FULL Trust as part of their hosting? I need to get out of the GoDaddy realm if this is going to continue to happen.
Thanks again for your feedback.
Bruce L
All-Star
18102 Points
2841 Posts
Re: GoDaddy Upload Image to Gallery Error (NEW)
Apr 12, 2010 09:05 PM|LINK
Jes.. only 1.1 offers full trust.. in case you don't realized, asp.net 4.0 was released today. Going back to 1.1 is like going back 2 generations.
I think your code already has the ability to insert the image into the DB.
You can check out our hosting service. http://www.discountasp.net
http://www.discountASP.NET
dude9er
Member
49 Points
176 Posts
Re: GoDaddy Upload Image to Gallery Error (NEW)
Apr 13, 2010 05:31 PM|LINK
Thanks for the feedback. I was actually able to get it to work using a SQLConnection