ooto.info

Finally up on CS2007 - getting ready for 2008 - it is AMAZING!

March 2007 - Posts

Control Panel Grid Size

I just found a nugget that I thought I'd share.  I have way too much spam in my blog - I'm working on tweaking my spam filters to get rid of more of it, but I digress...

I have the task of manually cleaning out all of the spam.  In CS2+, this isn't a bad task - you can see a good portion of the comment so you can "click-boom-click-boom" (I hate that commercial). 

Problem is, my control panel shows me 10 comments at a time.  That's not going to cut it - I've got over 8000 comments "awaiting" approval and probably 21 pages of spam that made it through my rules - hey man, I've got comments from Brittney Spears and Christina Aguilera.  Yeah, Jason Alexander is a regular reader - this is better than MySpace!

Anyway, there's some code in /ControlPanel/Blogs/Comments.aspx.cs that returns the page size of that grid - it's pulling an extended attribute from my user called CPPageSize - is there already somewhere that I can set this for my user?

Sure enough, in my user profile under the Site Options tab, there's a drop down to set the number of records returned in the grid - 50 it is!  I had no idea that was there. 

Custom Apps within Community Server

A few months ago, a client of mine asked for the ability to host a custom app from within their Community Server deployment.  Well, I got to working with TheMan and we built a web.config that basically restored the settings in a virtual directory within a CS deployment to the defaults for ASP.Net.

So - first, here's the requisite HelloWorld program.

How'd we do it - basically, we're going to reset, remove, clear, add:

  • Remove alll of the added assemblies by name.
  • Reset the page base type (if you're running ASP.Net 2.0)
  • Reset your custom errors
  • Remove httpModules
  • Remove httpHandlers
  • Reset your Authentication
  • Clear membership, role and profile providers and add your defaults from your machine.config

That's it - good luck!

You want more detail?  Ok - this article was written for a CS2.1.60809.935 running on ASP.Net 2.0.

In my web.config (which should be the one that comes with the CS2.1 download - a copy is available here), starting at the top, we find:

<compilation defaultLanguage="c#" debug="false">
     <assemblies>
          <add assembly="MemberRole, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b7c773fb104e7562"/> 
     </assemblies>
</compilation>

My helloworld app isn't going to use MemberRole, so let's kill it.  Take the web.config for your custom app and put in:

<compilation defaultLanguage="c#" debug="true"
     <assemblies
          <remove assembly="MemberRole, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b7c773fb104e7562"/> 
     </assemblies>
</compilation>

I use copy/paste.  If you're an old unix geek you can s/add/remove and you're set.

Continuing on... we find:

<pages validateRequest="false" enableEventValidation="false" autoEventWireup="true" pageBaseType="CommunityServer.Components.CSPage, CommunityServer.Components"/>

My helloworld app isn't going to use CommunityServer.Components.CSPage, etc, so let's kill it...  But what is the default pageBaseType?  Well - the Page class belongs to "System.Web.UI" so you can set this to System.Web.UI.Page.

Moving on...  Next I run into <httpModules> and <httpHandlers>.  Here, you just need to "remove" all of the custom settings:

<httpModules>
     <remove name="CommunityServer" />
     <remove name="CSProfile" />
     <remove name="CSRoleManager" />
</httpModules>

<httpHandlers>
     <remove verb="GET" path="Utility/redirect.aspx" />
     <remove verb="GET" path="aggbug.aspx" />
     <remove verb="GET" path="avatar.aspx" />
     <remove verb="GET" path="vcard.aspx" />
     <remove verb="GET" path="r.ashx" />
</httpHandlers>

Now we get into the custom providers that CS uses.  Luckily, there's a lovely <clear /> statement that we can use to blow away all of the providers.  This is a problem, though, because ASP.Net loads some default providers.  We need to add them back but I don't know off the top of my head what they are.  When in doubt, look at your microsoft.net/framework/CONFIG directory for the default setting.  Doing so, I find default membership, profile and roleManager providers in my machine.config and add the following lines to the end of my custom app's web.config and we're done!

 

  • <membership defaultProvider="AspNetSqlMembershipProvider">
    • <providers>
      • <clear />
      • <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
    • </providers>
  • </membership>
  • <profile defaultProvider="AspNetSqlProfileProvider">
    • <providers>
      • <clear />
      • <add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    • </providers>
  • </profile>
  • <roleManager defaultProvider="AspNetSqlRoleProvider">
    • <providers>
      • <clear />
      • <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    • </providers>
  • </roleManager>

 

Ok - here is the final web.config for my custom app. 

Blogmailr

An easy way to blog anywhere from the makrs of Community Server.

I originally wrote this post on my cell phone to test to see if Blogmailr posts supported Snippets - what do ya know - they do!  If you aren't blogging with Blogmailr, seriously, what are you waiting for.

Oh, and Blogmailr works for any blogging platform that supports the MetaBlogAPI so you don't have to be a Community Server usr... why you would blog with another platform is beyond me but, whatevr...