Medium trust (issues with image display)

Jul 17, 2007 at 4:28 PM
I'm trying to see if I can get this to work in a medium trust environment. As far as I can tell, the main things that are causing problems are the ajax stuff and the images stored in the file system. To test it, I simply placed this directive in web.config: <trust level="Medium"/>

My research tells me that I should have no problem uploading & displaying any files as long as they're contained within the website space. I'm using the code provided by MNebinger on storing the images in the file system - so I've got a folder called Pictures under my root website directory. No problem, right?

Wrong. All I'm getting are little red exes. I'm assuming it has something to do with file permissions on the file I created, but I'm not sure. Has anyone gotten this to work in a medium trust scenario? What am I doing wrong? Any help would be greatly appreciated.

The code is in usercontrols/imagefetch.ascx:

fileName = HttpContext.Current.Request.PhysicalApplicationPath & "Pictures\" & fileName
Dim imageFile As New FileStream(fileName, FileMode.Open, FileAccess.Read)
Dim len As Integer = CInt(imageFile.Length)
Dim d(len) As Byte
imageFile.Read(d, 0, len)
imageFile.Close()
output.Write(d, 0, d.Length)
Coordinator
Jul 17, 2007 at 5:46 PM
Use the latest source and see if that is also the problem. I have done all my image stuff in "file" mode, so it should work. Maybe you can't do file oporations in medium trust, I'm not completely sure.
Jul 17, 2007 at 7:34 PM
According to ms documentation you can as long as the folders are contained within your webspace.

My code for this is the same as the recent release as far as I can tell. Set your trust to medium and see what happens.
Jul 17, 2007 at 7:51 PM
Edited Jul 17, 2007 at 8:30 PM
Okay, I'm going to have to ask this question and I truly truly mean no offense. Why is this being developed in Full Trust when the bulk of the users of something like this are looking for a shared hosting environment?

I didn't even know about the whole medium vs. full trust until about a day ago. I thought I was ready to release this code into a production environment and now I've hit another wall. You can only imagine my level of frustration at this moment.

Aren't there only like two web hosts who are willing to open themselves up to Full Trust?

From what I'm reading, web hosts will suddenly change it to Medium Trust with little to no notification to their users. I just don't want to end up hosed down the line.

I'm just really frustrated.
Jul 17, 2007 at 9:25 PM
I had the same "revelation" about medium vs full trust when using this starter kit (as well as the CSK which requires Full Trust.) I am sure there are a number of hosts that open themselves to full trust but the two I have used personally are discountasp.net and ultimahosts.net. I have recently moved all of my sites over to ultimahosts.net because they are more economical for what I am doing and I have been happy with the results.
Jul 17, 2007 at 9:49 PM
I had a similar issue on a Persoanl Starter Kit I am doing for a photographer. It is hosted at Go Daddy. I had to disable front page extension, creaet teh directories using the go daddy admin tool and assign permissions. That solved the problem.
Coordinator
Jul 17, 2007 at 10:22 PM
Well, the problem is the file hosting. In a medium trust environment, you cannot pop images up into the file system without manually putting images in there.

The work arround is just using the database for your hosting.

So, to answer this question, "Why is this being developed in Full Trust when the bulk of the users of something like this are looking for a shared hosting environment?", IT IS. The images on file might not work in medium trust, that's why you can still host images on file.
Jul 18, 2007 at 12:32 AM
I use webhost4life as my shared host. I know that I had to create the directory manually with their web admin tool, and set the permissions for the aspnet account to be able to read and write before I could get the images to be stored on the file system.
Jul 18, 2007 at 2:18 AM
So Michael, do you know if there's any way to recreate this on my local machine? I don't want to spend money on a hosting plan and have nobody be able to access the site. I'm trying to work this stuff out locally.

And thanks for all the responses.
Jul 18, 2007 at 2:44 AM
The other issues I'm uncovering include: 1. The calendar doesn't work. 2. None of the Ajax stuff works.

It looks like nothing in the bin directory is supported, so it's weird that the fckeditor still works. I don't understand that one...
Coordinator
Jul 18, 2007 at 5:32 AM


Tina wrote:
The other issues I'm uncovering include: 1. The calendar doesn't work. 2. None of the Ajax stuff works.

It looks like nothing in the bin directory is supported, so it's weird that the fckeditor still works. I don't understand that one...


http://ajax.asp.net/docs/InstallingASPNETAJAX.aspx
Jul 18, 2007 at 1:18 PM
Thanks, Zach. Sorry for my frustration yesterday.

I was angry at myself and it got the better of me.
Coordinator
Jul 18, 2007 at 4:11 PM
Edited Jul 18, 2007 at 4:11 PM
It's ok... no need to apologize.

Did you get everything worked out?
Jul 18, 2007 at 4:37 PM
Not yet, but I think I'm just going to bite the bullet, buy a hosting package, and see how it behaves. I might be making myself crazy for nothing.
Coordinator
Jul 18, 2007 at 9:09 PM
You could trial some hosters. I know of these 2 giving out trials:

http://vwdhosting.net
http://www.ultimahosts.net/trial/Default.aspx
Jul 19, 2007 at 1:52 PM
Edited Jul 20, 2007 at 12:25 AM
I got it to work in a medium trust environment at edthosting. Yay!

So it can be done!
Coordinator
Jul 20, 2007 at 9:00 PM
Good! Glad to hear that.