Auto-provisioning blogengine.net

Topics: Business Logic Layer, Controls, Themes
Nov 14, 2011 at 10:48 PM

 

Greetings,

I'm trying to put together an auto-provisioning process so when a user signs up, s/he gets an instance of blogengine.net.  So let's say I have the following structure in IIS7

www.xyz.com/public/<customer id>/blog

What I'm currently doing is that I'm creating a directory under "public/<customer id>" relative to my root and I copy and paste the whole shabang of files and directory of blogengine.net to that location. The problem is blogengine.net doesn't work (won't show up) unless and until I go to IIS manager MMC and add the public/<customer id>/blog directory as an "Application."  AFter I make the directory an application, then it works.  If I don't do that and try to browse that location, I get

[code]

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.

Source Error:

Line 7:    </configSections>
Line 8:    <BlogEngine>
Line 9:      <blogProvider defaultProvider="XmlBlogProvider">
Line 10:       <providers>
Line 11:         <add name="XmlBlogProvider" type="BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core"/>

[/code]

 

I tried adding a virtual directory using "appcmd.exe add vdir blah blah" and while it says that the vertial directory has been added, the blogengine doesn't show up.  Again, but if I go to IIS7 manager and right-click and do a Add Application on that directory, everything works.

The whole point is to create an instance of the blogengine.net for each user so they'll isolated from each other in as much as hands-off fashion as possible.  It would have been nice if I could factor out all the common elements from all the instances and just specify the attrtibutes but for now, I can live with each having their own set of files if I can get it to work.  Any and all suggestion is apperciated and thank you in advance.  Please let me know if I can clearify anything.

 

 

 

Coordinator
Nov 15, 2011 at 7:02 AM

It's true that if you setup a whole new BE installation by copying all of the files like you are doing, then that new folder needs to be marked as an application in IIS.  It sounds like this process of creating an application works using the IIS7 manager, but doesn't work using appcmd?

One suggestion I have which you may have already considered is that with BE 2.5, it supports multiple blog instances.  Explained here.  With multiple blog instances, you only install BE one time, and within the BE control panel, you can create blog instances.  Each blog instance has its own set of data, its own users, etc.  You can also create new instances from a "template" (you can have multiple templates as well).  So you might have a single template, and you create new blog instances from that template.  The instances are pretty isolated from one another.  You can use the "virtual path" option to have one of the blog instances (aka sub-blogs) have a URL such as ~/customerid (with or without /blog at the end).  A physical directory won't be created -- instead BE will pick up on that URL (intercept it) and treat the request as being a request for that blog instance.

Or you could go the appcmd way.  I'm not sure offhand though what is differing between appcmd and the IIS7 UI manager.  I'm thinking that taking advantage of the multiple blog instances might be most ideal.

Nov 15, 2011 at 9:21 AM

Thank you Ben for you reply.  So far I tried both appcmd.exe and using the following code to create an "Application" in IIS7. 

ServerManager serverManager = new ServerManager ();

 Site site = serverManager.Sites.First(s => s.Id == 1);

 string n = "/public/" + id + "/" + "blog" ;

 Application app = site.Applications.Add(n, @"c:\\dfun\\public\\" + id + "\\blog" );

 app.ApplicationPoolName ="MyPool";

 serverManager.CommitChanges();

 

In both cases the virtual directory is created but I get a 500 error when I try to go there.  But if I use IIS7 MMC and right-click and do "Convert To Application" it works - go figure.  Event logs are clean.  The exact error message below.  Not sure what else "Convert To Application" does that other processes don't...



Any thoughts?





HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information

Module

IIS Web Core

Notification

BeginRequest

Handler

Not yet determined

Error Code

0x8007007b

Config Error

Cannot read configuration file

Config File

\\?\c:\\dfun\\public\\203\blog\web.config

Requested URL

http://www.xyz.org:80/public/203/blog

Physical Path

c:\\dfun\\public\\203\blog

Logon Method

Not yet determined

Logon User

Not yet determined

Config Source

   -1: 
    0: