Thursday, February 28, 2008

Configuration SiteCacheRefresh in Commerce Server 2007 and solve erros

Support for refreshing Commerce Server caches is provided by the SiteCacheRefresh HTTP Handler and is configured in the web.config:



<httpHandlers>
<add verb="*" path="SiteCacheRefresh.axd" type="Microsoft.CommerceServer.Runtime.SiteCacheRefresh,
Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
"/>
</httpHandlers>



ASP.NET URL authorization is used to specify the users and groups allowed to refresh the cache.






<location path="SiteCacheRefresh.axd">



<system.web>



<authorization>




<allow roles="BUILTIN\Administrators"/>




<deny users="*"/>




<deny users="?"/>
</authorization>
</system.web>
</location>


ASP.NET site will use forms authentication.
The above ASP.NET URL authentication requires IIS to use Windows Authentication.
If you do not implement a mixed authentication
solution on your retail site, each request to SiteCacheRefresh.axd will be redirected
to the forms authentication login page as specified in the web.config.







<authentication mode="Forms">





<forms loginUrl="~/Login.aspx"/>




</authentication>







A mixed authentication model must be implemented
for SiteCacheRefresh.axd authorization. The Commerce Server Starter Site provides
such a solution.










Enable Mixed Authentication:



  • Make sure your ASP.NET site has Windows Integrated security checked in IIS Admin.


  • Copy the CommerceComponents.dll from the Starter Site bin directory to your retail
    ASP.NET web site’s bin directory.


  • Add the following entry to the configSections element of your web.config.










    <section name="commerceComponents" type="CommerceComponents.Configuration.ComponentConfiguration,
    CommerceComponents" />

    • Add the following entries to the configuration element of
      your web.config.






    <commerceComponents baseCurrencyCode="USD" baseCurrencyCulture="en-US">
    <mixedAuthenticationFiles>
    <add fileName="SiteCacheRefresh.axd" />
    </mixedAuthenticationFiles>
    </commerceComponents>




  • Add the following entries to the httpModules element of your
    web.config.




    <clear />
    <add name="OutputCache" type="System.Web.Caching.OutputCacheModule"
    />
    <add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule"
    />
    <add name="MixedModeAuthentication" type="CommerceComponents.MixedAuthenticationModule"
    />
    <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"
    />




    <add name="MixedModeAuthenticationFixUp" type="CommerceComponents.MixedAuthenticationModuleFixUp"
    />




    <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule"
    />




    <add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule"
    />




    <add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule"
    />




    <add name="Profile" type="System.Web.Profile.ProfileModule"
    />




    <!-- COMMERCE SERVER HTTP MODULES


    Place the Commerce Server HTTP module declarations below this line.


    -->



    Errors:

    You may have encountered an error when trying to run a
    Cache Refresh
    from within a Business Management Application
    such as the Catalog Manager
    or when trying to run a Commerce Server Staging
    Project
    with Refresh Cache enabled on one of the following resources
    (Catalog, Marketing or Orders).


    1. Many Errors with System.Web.Services.Protocols.SoapException have been solved by service Pack1

    • 404 File Not Found
      Solution:
    1. Validate you add key of SiteCacheRefresh to HTTPHandlers
      of Web.Config of the site.
    2. Validate Url in Web.Config
      http://<WebServerMachineName>/OrdersWebService/SiteCacheRefresh.axd?CacheToRefresh=CatalogCache
    3. You may already have another Site using the <WebServerMachineName> as
      a Host Header value.
      So, how do you change the <WebServerMachineName>

      You can change it from the database (PropertyName s_WebServerMachine) for site resource.
    • [Win32Exception (0x80004005): The handle is invalid]

      Solution:
      Validate Mixed Authentication is enabled from Steps above. Make sure you deny anonymous or everyone and allow users have access to the module. You can’t test mixed authentication from the site, you should use external application.




    • After Calling RefreshSiteCache.axd and checked the event
      Log I found message:
      The cache 'CatalogCache' has been refreshed for the site 'Contoso'(didn’t generate errors). But when I checked the site, I didn’t find data updated.
      Solution: Review HTTP Modules in Web.Config