Monday, September 12, 2016

Error in sitecore mvc routing: An illegal route has been detected: '{controller}/{action}/{id}'

If you are working with Sitecore with MVC and you face the below issue then you can resolve the below issue by commenting the below lines from RouteConfig.cs file(screenshot) and publish.

Issue:
The following fatal error have been detected:
1: An illegal route has been detected: '{controller}/{action}/{id}'. If you wish to keep this route, please remove it from the Mvc.IllegalRoutes setting.


Resolution:


Sunday, September 11, 2016

Version conflict with System.Web.Mvc

Few days back while compiling our project we are getting the below error.We spend a long time to resolve the issue and finally got the solution..


Assembly 'System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
 uses 'System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
 which has a higher version than referenced assembly 'System.Web.WebPages, Version=2.0.0.0,
 Culture=neutral, PublicKeyToken=31bf3856ad364e35'      
  c:\inetpub\wwwroot\WebsiteSiteCM\Website\bin\System.Web.Mvc.dll website.Retail.Web

You may also try to reinstall Microsoft.AspNet.WebPages nuget packages using this command in the package manager console
> Update-Package –reinstall Microsoft.AspNet.WebPages 

How to reset Admin password to default password b in Sitecore

It might happen we forgot or lost admin password in Sitecore. Then there is a simple way to reset the admin password to "b"

Steps:
1. Navigate to Core database.
2. Run the below query in core database and it will update to default password to b.

UPDATE dbo.aspnet_Membership
SET
    Password='qOvF8m8F2IcWMvfOBjJYHmfLABc=',
    PasswordSalt='OM5gu45RQuJ76itRvkSPFw=='
WHERE  UserId = (SELECT UserId FROM dbo.aspnet_Users WHERE UserName = 'sitecore\Admin')


Wednesday, June 22, 2016

If there is mongodb connectivity issue in production what will happen?

Yesterday I have got a query from our client that in production if there is a mongodb connectivity issue for time being what will happen to website from user end? The question was really interesting to me. I thought the website might not be available for that time period and gave the answer to client.

Later I thought that I am doing some mistake and searched google and from SDN I got to know that if mongodb  is not available then..

1. From a user's perspective, the site will continue to function normally unless  we are doing any personalization or custom logic based on data directly from MongoDB.
2. The Experience Analytics dashboard pulls data from the reporting SQL Server database, which contains aggregated data from MongoDB, so it will continue to function, however, our metrics will eventually flat-line as new data will not being captured with an invalid/broken MongoDB connection
3. Will see errors in the Sitecore logs file related to failed connection attempts.
4.  Website will be available but traffic will not be logged on xDB.





Wednesday, May 25, 2016

Custom Processors in Sitecore


If the processor has a method, the method must accept a PipelineArgs object and return type will be void. Below code snippet will help us to write simple custom processor in Sitecore.


 public void Process(AverageRatingProcessorArguments args)
        {

            double average = 0;
            String ConStringName = Sitecore.Configuration.Settings.GetSetting("ratingconstring");

            using (SqlConnection connection = new SqlConnection(ConStringName))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand("Getaverage", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@BlogItemID", args.itemID);
                    average = (double)command.ExecuteScalar();
                }
            }
       
            args.CustomData.Add("averagerating", Convert.ToString(average));
        }


 public class AverageRatingProcessorArguments:PipelineArgs
    {
        public string itemID { get; set; }

    }

//Invoking the custom processor
public string AverageRatingWithProcessor(string itemID)
        {
             
            RatingModule.Processors.AverageRatingProcessorArguments ARarg = new RatingModule.Processors.AverageRatingProcessorArguments();
            ARarg.itemID = itemID;          
           
            CorePipeline.Run(AVERAGE_RATING_PROCESSOR, ARarg);
            var AvgRating = ARarg.CustomData["averagerating"];

            return AvgRating.ToString();
        }

Wednesday, May 18, 2016

MongoDb Data is updated after your session end

After session end the data is sent to MongoDb but during development phase will you wait for the time when the session will be abandoned?I think you will say "No". So we can do one thing on that time that we can explicitly kill our session.

Steps:
create a simple abandon.aspx page and place it within [Sitecore Instance Name]/sitecore/admin folder and call the abandon.aspx page explicitely like [Sitecore Instance Name]/sitecore/admin/abandon.aspx
Code snippet for abandon.aspx
<% Session.Abandon();%><html><head></head><body><h1>Kill the session</h1>
>
We forcefully Abandon the session.</body></html>
Calling the "abandon.aspx" page


?


Monday, May 16, 2016

What is difference between droplink and droplist in Sitecore?


Today one of my friend asked me what is the basic difference between Droplink vs Droplist in very simple words. I replied that...

Droplink:
Droplink  stores the GUID(Unique in space and time) of the item that was chosen by content editor.

Droplist:
Droplist data type only stores the string value of the item that was chosen by the content editor.