1
Vote

Medium Trust issues

description

I'd like to begin by thanking you for the starter site. It encompasses some great ideas and has great code. However, many developers, myself included, build sites for clients that need to be hosted with ISP's who host them under medium trust. So its a wise idea to enter this line in web.config during development
<system.web>
<trust level="Medium"/>
This ensures the site will function correctly in a medium trust environment without having to wait until you move it to the ISP. Quite often things work great on our dev box, but then a lot of security exceptions begin to show up when a site is moved to a medium trust environment. I noticed this with the starter kit. When I added the above line, I started to run into issues immediately. My first one is with Ninject. I got the dreaded security exception. However, I was able to fix it with a slight code modification in global.asax.cs: Just add a line for settings and slightly alter the creation of the kernel.
    public static IKernel Container {
        get {
            if (_container == null) {
                // add below line and ninject will work in medium trust
                var options = new NinjectSettings { UseReflectionBasedInjection = true }; 
                _container = new StandardKernel(options,new SiteModule());
            }
            return _container;
        }
    }
This solved the Ninject issue nicely. However, I cannot get NJog to work in medium trust so was wondering if anyone knows of a good .net logger that will work in medium trust. This is as far as I've gotten with this post. It would be great if others would jump in with the goal of creating a version of the starter kit that will work out of the box in a medium trust environment.

Many Thanks,

Ed

comments

msony wrote Sep 4, 2010 at 7:33 AM

i have the same issue only when i in release mode with debug works for me :(