Security Exception

Topics: ASP.NET 2.0
May 29, 2007 at 9:03 AM
first: this is a great project and is written in a very clean way making it easy to understand everything in the code.
But I cannot make it run... It runs smooth on my machine, but when I copy it on the server it gives me a System.Security.SecurityException (please look at the complete error page at I know this could be a "trust" issue, but I cannot manage the server (is a low cost service...) and I cannot change to another provider. Is there a way to modify BlogEngine in order to make it run anyway? Which operation is "not allowed by the security policy"?

Thanks in advance to everyone

May 29, 2007 at 3:07 PM
In web.config, set the trust level from High to Medium
May 30, 2007 at 9:46 AM

madskristensen wrote:
In web.config, set the trust level from High to Medium

Hi, thanks for your answer.
I already tried to change the trust level, but "...the site administrator has locked access to this section using <location allowOverride="false"> from an inherited configuration file.". At least unpleasant.
In a early version of BlogEngine I solved the problem commenting out the trust level line in web.config, but it doesn't work with this release.

Thanks again :)
May 30, 2007 at 9:37 PM
I had the same problem and not really the time to go deep into the problem.
What I did was some changes in the 'BlogService.cs', recomplied and exchanged the dll (thank goodness for open source....):
    private static void LoadProviders()
      // Avoid claiming lock if providers are already loaded
      if (_provider == null)
        lock (_lock)
          // Do this again to make sure _provider is still null
          if (_provider == null)
            // Get a reference to the <blogProvider> section
            //BlogProviderSection section = (BlogProviderSection)WebConfigurationManager.GetSection("BlogEngine/blogProvider");
            // Load registered providers and point _provider
            // to the default provider
            //_providers = new BlogProviderCollection();
            //ProvidersHelper.InstantiateProviders(section.Providers, _providers, typeof(BlogProvider));
              _provider = new Providers.XmlBlogProvider();//_providers[section.DefaultProvider];
            if (_provider == null)
              throw new ProviderException("Unable to load default BlogProvider");

This will hard-code the BlogEngine.Core.dll to use the XMLBlogProvider, not so good maybe, but it worked for me.....
May 31, 2007 at 9:14 PM
Great! It works now! Thank you very much goranh.
I still have problem with the blog roll (it seems that I cannot perform a "WebRequest.Create"), but I don't need it at all.

Thanks again, I'm sure that this information will be usefull to a lot of people.
Oct 9, 2007 at 10:14 AM
I am facing similar problem:

When I was using the 1.1 version this workaround absolutely SOLVED the problem , and I was able to login, post and everything, only problem that was still there (as stated) was the blogroll , but that was not a big issue for me...

Now, I updated to 1.2, got to the same C# source and changed the default provider to hardcode to XML like I did for the 1.1... but this time, it's NOT working ...

I cannot login anymore, the system keep answering "login failed, retry" and I cannot enter any kind of editing or update of the blog...

I know this is a "minor" since most of the blog users have better hosts...but if anyone can help me out... thanks in advance...