Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ian Robinson 79 posts 143 karma points
    Jul 24, 2012 @ 23:43
    Ian Robinson
    0

    Using more than one assembly in restExtensions.config

    Can I use more than one assembly in base?  I've tried adding each assembly and even swapping them around in the config file.  Whichever one is specified first works while the second does not.

    <?xml version="1.0" encoding="utf-8"?>
    <RestExtensions>
       <ext assembly="Umbraco.ChilliIS.cForum" type="Umbraco.ChilliIS.cForum.code.BaseExtensions" alias="BaseExtensions">

        <permission method="CreateForumTopic" allowType="ActiveDirectoryMember" returnXML="false" />
        <permission method="CreatePost" allowType="ActiveDirectoryMember" returnXML="false" />
        <permission method="MarkReplyAsSolution" allowType="ActiveDirectoryMember" returnXML="false" />
        <permission method="SubscribeToTopic" allowType="ActiveDirectoryMember" returnXML="false" />
        <permission method="UnSubscribeToTopic" allowType="ActiveDirectoryMember" returnXML="false" />

      </ext>

      <ext assembly="Umbraco.ChilliIS.cBlog" type="Umbraco.ChilliIS.cBlog.code.BaseExtensions" alias="BaseExtensions">
        <permission method="CreateBlogComment" allowType="ActiveDirectoryMember" returnXML="false" />
      </ext>
     
    </RestExtensions>

  • Ian Robinson 79 posts 143 karma points
    Jul 24, 2012 @ 23:48
    Ian Robinson
    0

    To be more precise, any call to the method in the second assembly, i.e. http://domain_name/base/BaseExtensions/CreateBlogComment returns a server 500 error containing this response:

    <error><![CDATA[MESSAGE: Object reference not set to an instance of an object.  STACKTRACE:  at umbraco.presentation.umbracobase.requestModule.invokeMethod(restExtension myExtension, Object[] paras)  INNEREXCEPTION: ]]></error>
  • Ian Robinson 79 posts 143 karma points
    Jul 25, 2012 @ 10:27
    Ian Robinson
    0

    I think I've found why I was a problem.

    I used the same alias for both assemblies.  Once I changed:

    <ext assembly="Umbraco.ChilliIS.cBlog" type="Umbraco.ChilliIS.cBlog.code.BaseExtensions" alias="BaseExtensions">

    to:

    <ext assembly="Umbraco.ChilliIS.cBlog" type="Umbraco.ChilliIS.cBlog.code.BaseExtensions" alias="BlogBaseExtensions">

    And updated my ajax call to "/base/BaseExtensions/CreateBlogComment" to "/base/BlogBaseExtensions/CreateBlogComment" instead, the method was being called properly.

     

  • Ian Robinson 79 posts 143 karma points
    Jul 25, 2012 @ 10:53
    Ian Robinson
    0

    I've found a better solution.  I've removed the entries from restExtensions.config and put some rest attributes into my class instead.

     [RestExtension("BaseExtensions")]
        public class BaseExtensions
        {
           
            /// <summary>
            /// Creates a comment against a blog post.
            /// </summary>
            [RestExtensionMethod(allowType = "ActiveDirectoryMember")]
            public static string CreateBlogComment()
            {
                // all code is here
            }
    }

    I think this is a better solution than using restExtenstions.config because:

    1) I can use whatever alias I like and it doesn't appear to conflict with any other rest alias that might have been set by another package.  i.e. in the example above my cBlog package is using the alias BaseExtensions and so is my cForum package. 

    2) Putting the attributes in the class itself means I don't have to alter the Umbraco site's restExtenstions.config, so there's no need to add a package install and uninstall action to update the file.

    If anyone has the same issue as myself, there's an example of using the attributes in the wiki at http://our.umbraco.org/wiki/reference/umbraco-base/simple-base-samples.

Please Sign in or register to post replies

Write your reply to:

Draft