Skip to content
August 22, 2016 / kiranpatils

Inheriting Sitecore Site Properties with Sitecore Patching and Transformation

Challenge:

Sitecore is such a huge platform that every day you find something new and interesting. Happens with you as well? It is happening with me since last 7+ years!😉 But I am enjoying learning it and then sharing it with you.

So, let’s say you have one site node defined with all basic things e.g. enablePreview, enableWebEdit, hostName, startItem, database etc. It has hostName as “www.scbasics.com”. Now you would like to have one more site where you would like to use base attributes as earlier defined and you would like to modify few attributes only:

<sites>
  <site name="site1" virtualFolder="/sitecore/admin" physicalFolder="/sitecore/admin" enableAnalytics="false" domain="sitecore" loginPage="/sitecore/admin/login.aspx"/>

  <site name="site2" inherits="site1" />
  <site name="site3" inherits="site1" domain="extranet" />
  <site name="site4" inherits="site1" enableAnalytics="true" />
</sites>

Source : http://sitecoreskills.blogspot.com/2014/08/inheriting-sitecore-site-properties.html

I also did the same and it worked in local. But when I deployed it on QA/Dev server. It was not working. After spending sometime learnt something which I would like to share with you as well. You might see it in future or might be already facing it and reading this blog to find a way!🙂 Let’s go!

Solution:

As you would have done, I also did showconfig.aspx on server and then noticed that my site2 was getting added before site1 and that was causing this issue and it was happening because I was using SlowCheetah Transformation and inserting site2 based on environment. To fix it — I used patch:after=”site[@name=’site1′]” which fixed this issue. Here is how it looks new with transformation

<sites>
  <site name="site2" inherits="site1" patch:after="site[@name='site1']" xdt:Transform="Insert" hostName="site2.com" domain="extranet" enableAnalytics="true"/>
  <site name="site3" inherits="site1" domain="extranet" /> 
</sites>

Good read :

http://sitecore.unic.com/2014/08/08/enable-multi-level-site-property-inheritance

https://sitecoreclimber.wordpress.com/2015/10/31/how-to-set-up-a-multi-site-solution/

Happy Patching!🙂

August 22, 2016 / kiranpatils

Configuring Web Deploy on your Sitecore server

Challenge:

Last week one of my mates was trying to configure Web deploy with Build server and CM/CD Server and they were facing some challenges to get it done. We have done it so many times in the past. But as we haven’t had it documented we set together and fixed it. But then I promised to blog it and here you go!

Solution:

Microsoft folks have already written nice documentation here : http://www.iis.net/learn/install/installing-publishing-technologies/installing-and-configuring-web-deploy-on-iis-80-or-later

This document is quite huge I know and in this fast paced world. Who has time to read through all that document. So, you are looking for important steps? Here are those:

  1. To install : Refer section :”Using the Web Platform Installer to install Web Deploy Separately”
  2. To configure : Refer section : “Configuring a Site for Delegated Non-Administrator Deployment”

That’s it!

You are facing challenge with your Web deploy configuration? Feel free to get in touch with me. Because I have spent good amount of time troubleshooting it (and before that understanding it) and this post is proof of it.

Happy Deployment!🙂

 

June 3, 2016 / kiranpatils

Unable to see components on Stats.aspx page for your Sitecore 8 MVC site?

Challenge:

We are near to launch one of our new site. Built on Sitecore 8.1 U1 and MVC, GlassMapper, TDS etc. As per our practice we applied HTML caching on all possible components. Which we were verifying whether it is working as per expectation or not. One of the way to do is using stats.aspx page. But when we opened it. It was displaying only one component — VisitorIdentification — Which is more of a Sitecore control. Then what happened to all our renderings? Same with you? Or you would like to be proactive? And eager to know what it was. Then this post is for you. Let’s delve in to it.

Solution:

As expected. We did a quick Google search and came across of this blog : https://blog.wesleylomax.co.uk/2015/11/20/sitecore-8-mvc-custom-site-not-showing-stats-aspx-page/

Two things came out from this blog post:

  1. This guy was unable to see his sites, where I was able to see site. But not renderings
  2. Required files were not attached.

Again, as expected. Raised Sitecore support ticket and they accepted it as BUG and provided Hot fix:

To fix the issue, please consider deploying the following patch:
1. Copy the attached Sitecore.Support.398176.dll assembly to the ‘\bin’ folder.
2. Copy the attached Sitecore.Support.Mvc.Statistics.config file to the ‘\App_Config\Include’ folder.

If there are any issues with this patch, please let us know. More information about Sitecore patches can be found here: https://kb.sitecore.net/articles/077333

To track the future status of this bug report, please use the reference number 94421. More information about public reference numbers can be found here:
https://kb.sitecore.net/articles/853187

Files can be downloaded from here :https://goo.gl/18BGgV

It worked? Awesome!

So, what was the issue? I am glad you are still reading. Lot of folks might have closed for the day. But I appreciate yo being curious to ask basic question “Why?”. Let me share what I understood:

  1. It looks recording stats information was not done for MVC pipeline or it might have been done at wrong place which was not working – Sitecore guys know it better. I am just assuming it here
  2. There are two IMP. pipeline in MVC <mvc.renderPlaceholder> and <mvc.renderRendering> where this guys have hooked code for recording that information e.g.    Statistics.AddRenderingData(…)

Special thanks to Pushpraj Ruhal (Sitecore support) guy who worked on this issue

May 27, 2016 / kiranpatils

How I learnt Sitecore MVC?

Challenge:

Before few months back. I started delving in to Sitecore MVC. Before that I knew basics of it. But no hands on. As I was busy with launching other site. Initially when I searched I found the lot of articles and blogs which scared me! You too?! Google can give you results. But which are best and which are not. You can find it out either trying or finding out other folks who already tried and provide good articles. So, while working I took some notes and I promised my self that once I am done I will share with you. So, you may get benefited out of it.

Sounds interesting? You are also searching for something like that? Then go ahead..!

Solution:

As per my practice. I started understanding ASP.NET MVC. Because i always believe in starting from basics. And following links helped me to do so:

  1. http://www.asp.net/mvc/overview/getting-started/recommended-resources-for-mvc
  2. http://www.asp.net/mvc/videos/pluralsight-aspnet-mvc-5-fundamentals
  3. https://mva.microsoft.com/en-US/training-courses/introduction-to-asp-net-mvc-8322?l=nKZwZ8Zy_3504984382
  4. http://www.w3schools.com/aspnet/mvc_intro.asp
  5. http://www.asp.net/mvc/overview/getting-started/mvc-learning-sequence
  6. https://msdn.microsoft.com/en-us/library/dd381612%28v=vs.100%29.aspx
  7. https://msdn.microsoft.com/en-us/library/dd381412%28v=vs.100%29.aspx

Then moved to Sitecore MVC:

  1. http://www.sitecore.net/learn/blogs/business-blogs/technical-trends/posts/2012/06/mvc-and-sitecore-651-overview.aspx
  2. http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2015/02/how-is-sitecore-mvc-different-from-aspnet-mvc.aspx
  3. https://sdn.sitecore.net/upload/sitecore7/72/sitecore_mvc_developer_guide_72-a4.pdf
  4. http://sitecore-community.github.io/docs/sitecore-mvc/
  5. http://sitecore-community.github.io/docs/sitecore-mvc/creating-project/
  6. http://www.joe-stevens.com/2014/08/17/sitecore-mvc-tutorial-creating-your-first-sitecore-mvc-website/
  7. https://github.com/Sitecore-Community/sample-sitecore-mvc

I liked following excerpt from Lars – Especially RCMV and this diagram!

MVC stands for Model, View and Controller, though I have never understood the order of the abbreviation (by my limited intellect, RCMV would have been more appropriate, with a Route being a significant part of the equation).
Essentially, the request lifecycle of MVC is a Route (usually something that parses the http request) points to a Control (some .net code) which generates a Model (object), which is parsed by a View (usually a Razor view).
MVC Request Lifecycle
This approach is distinctly different from Web Forms, because it requires more code plumbing to create the page, and with less automated code reuse. On the other hand, the developer has more rigid control of the code executed on the page, and the data delivered to the output. Also, not to forget, MVC makes unit testing easier as (most of/all) the code usually is executed in the controller part of the lifecycle.

In my opinion, MVC is well suited for web sites with application functionality (e.g. HTML 5 applications).

Okay, enough theory. I know you developers!🙂 We need some action now. So, thought to look for some quick start application tried lot of things. But few things were out dates or not properly documented. Finally Martina’s video helped me to give a hands on. I strongly recommend you to follow exercise given in tutorial. It will give you good hands on experience. Which will boost your confidence and clarify your concepts a lot!

I faced some challenges in quick start. But life is NULL without challenge. And your best learnings come out of a challenging situation only. Here are few blog posts helped me to come out of it:

  1. http://sitecoreskills.blogspot.in/2014/06/preparing-sitecore-72-and-mvc-in-visual.html
  2. http://www.seanholmesby.com/fixing-visual-studio-intellisense-in-sitecore-mvc-views/ – Especially for Intellisense
    1. If you are using Project and Webroot model then make sure you copy web.config from Sitecore root to project
    2. Make sure Sitecore.MVC is there in reference
    3. Sitecore.MVC and Sitecore.Kernel – Is Copy Local  true
    4. Or final resort copy all webroot/bin assemblies to project/bin
  3. http://stackoverflow.com/questions/24147846/system-web-webpages-html-htmlhelper-does-not-contain-a-definition-for-sitecor/24152053#24152053

MVC is fun! It is like Maths — Once you understand it. You would like to do it again and again!

Further reading:

  1. http://blog.alen.pw/2012/08/learning-sitecore-mvc-part-1.html
  2. http://blog.alen.pw/2012/08/learning-sitecore-mvc-part-2.html
  3. http://www.matthewdresser.com/sitecore/moving-to-sitecore-mvc
  4. http://techitpro.com/sitecore-mvc/http://www.dotnet-tricks.com/Tutorial/mvc/a9P1010113-MVC-Areas-with-example.html
  5. http://www.codeproject.com/Articles/714356/Areas-in-ASP-NET-MVC
  6. https://community.sitecore.net/developers/f/8/t/108s
  7. https://sitecore.unic.com/2015/06/24/the-sitecore-mvc-puzzle
May 27, 2016 / kiranpatils

Looking for good 301 Redirect module for your Sitecore site?

Challenge:

Howdy friends, Sorry for being away for a while. But was busy with lot of things. I am back here to share my new Sitecore basics with you!

We have been revamping our site on newer Sitecore version. And we are near to launch. Site is already live and we have few sections/pages which are already indexed by Search engines and people might have already bookmarked it. But in new site those pages section has been changed or they have been moved. Sound similar? I guess most sites will have this challenge.

And as you would have done in this case. We also searched for good Sitecore 301 Redirect module. But I have been overwhelmed with lot of results, module and options. But to be honest, we were looking for simple solution which should do following things:

  1. Look for exact source URL and redirect it to either internal item or external URL
  2. Look for pattern and redirect to URL — Might want to preserve querystring

Simple?! You are also looking for same. Then this post is for you! Keep reading..

Solution:

After spending some time going through each module. This module took my attention : https://marketplace.sitecore.net/en/Modules/3/301_Redirect_module.aspx Because it looks simple, rating is high, and github is active!

We downloaded required package and installed it : https://github.com/thecadams/301RedirectModule

Now, you are all set!

  1. All redirects resides under: /sitecore/system/Modules/Redirect Module. So, If you have content authors role. Make sure they have access
  2. I faced some issue in my local with SC 8.1 Updated1 – Where for one of the item Response Status — Item’s version was not created. So, If you also face such issue. Please double-check each item and field have versions created
  3. There are two type of redirects :
    1. Redirect Url : Here you can provide Source URL and then where to redirect – You can redirect to Item or specific URL — We recommend Response Status Code as 301 – Moved Permanently. So, Search engines know that this page has been shifted to new URL. Mostly this will have one to one mapping. Example: When request comes from : http://localhost.SCBasics.com/demo.job-postings/job-detail?jid=16846 it should redirect to : http://localhost.SCBasics.com/job-search/job-detail?jid=16843
    2. Redirect Pattern: This can be used to group by URLs. When you have source URL request matching some pattern and you would like to redirect on particular item you can use this. As per below example any request coming from any URL having job-posting/job-detail (Pattern : ^/job-postings/job-detail(?<OptionalQueryString>\?.*)?$) in URL should be redirected to Job Detail page with QueyrString (/sitecore/content/SCBasics/Job Search/Job Detail${OptionalQueryString)
  4. For more examples please refer : https://github.com/thecadams/301RedirectModule#examples
  5. It also provides N number folder support. So, It is good practice to follow it!
  6. And If you have a lot of redirects and would like change how redirect item gets resolved (fast, query, api) or would like to change where this module looks for 301 Redirect items then have a look at : SharedSource.RedirectModule.config

That’s it!

Happy Redirection!🙂

April 2, 2016 / kiranpatils

Sitecore Automatic Deployment learnings

Challenge:

Last week have been spending some time configuring Automatic deployment using Team city for one of our new project (If you are new to Team City and Sitecore automatic deployment. I would encourage you to search and read on that topic. It makes your deployment process smoother!) . The steps are clear, tried, tested and documented. But still faced some issues while configuring it. [Life won’t be boring? If everything works as per documentation🙂] So, thought to share with you as well!

Ready? Let’s go:

Solution:

  1. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4331, 5): The value for PublishProfile is set to ‘QA.CM’, expected to find the file at ‘C:\BuildAgent\work\dcf5173b83de3020\SCBasics.Website.Web\Properties\PublishProfiles\QA.CM’ but it could not be found. : We use Web Deploy for publishing and for that have add Publish Profile which has been named as QA.CM. Initially I thought it might not get pulled over using Team City. But after verifying at given directory — File was there. This issue puzzled me for around 12 hours and then did a quick search and it revealed thisYou can’t have . (dot) while naming Publish Profile name — Replaced . by – and now name looks like this QA-CM — And it works!
  2. sitecore\content\Global\ABC.item(1, 0): error TDS0005: Deploy of /sitecore/content/global/abc failed. Reason: Error reading item: /sitecore/content/Global/abc
    Failed to load version 1 for language en Length of field content does not match the content-length attribute. Field name: ABC Field, field id: {32E448F6-6A9F-4DEA-8F1D-C420F9586918}
  3. sitecore\media library\SCWebsite\Images\Story Slides\XYZ.item(1, 0): error TDS0005: Deploy of /sitecore/media library/SCwebsite/images/story slides/xyz failed. Reason: Failed to paste item: /sitecore/media library/SCWebsite/Images/Story Slides/xyz
    The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

By looking at #2 and #3 — You will jump out of your chair and say – Hey I know “content-lenghth” issue’s solution. It is easy. Just follow this blog and you will be done : https://theagilecoder.wordpress.com/2013/03/02/tds-so-youre-deploying-sitecore-to-a-new-environment/But life is not as easy as it seems to be! We already did that blog for Local and it works! (Thanks to Jason!). But still we were facing this issue while deploying Sitecore items on Target environment using  Team City. Then quick search pointed out this : We needed to enable the “convert line endings to CRLF” in the Git VCS plugin settings for TeamCity (Reference : https://jrodsmitty.wordpress.com/2015/01/20/team-development-for-sitecore-tds-github-teamcity-and-line-endings-oh-my/)

Now, We can deploy on QA CM and CD Environments with just one click and deployment gets completed with .NET/Sitecore files, Sitecore Items and publishing as well in 3-5 Minutes!

As I mentioned earlier. There are plenty of blogs on web about doing Sitecore deployment using Team City and that’s why have not written anything on it. But let me know If you want me to write (One of my reader — Requested me to do so — But haven’t had a chance to do so. And I believe If I do now. It might not add value)

Hope this helps!

Happy Deployment!🙂

February 6, 2016 / kiranpatils

Reflector tips and tricks every Sitecore Developer should know

In this week whole Sitecore community heard a BIG News that our Sitecore Guru has decided to Bid Farewell to Sitecore community. Whole community was there to wish him luck! And it has a reason. Lot of us (Including me!) started Sitecore coding looking at his blog. In those days. When no Sitecore documentation/blogs were available in the universe except Sir John West’s blog and SDN Forum replies. It is true “Passion is contagious!”

Would like to dedicate this blog post to SirJohn West!

https://community.sitecore.net/general/f/13/p/2524/7208#7208

As Sir John West mentioned here that Reflector is a cool tool to have : http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2011/05/cool-tools-for-sitecore-aspnet-cms-developers.aspx

We know that there are a lot of options available which are free. But somehow I love and prefer to use Reflector. I know it’s paid. But it’s worth. If you would like to convince your boss then give them this link from Joel’s blog : http://www.joelonsoftware.com/articles/fog0000000043.html Tip #9

I have seen that lot of Developers (Senior or Junior) prefer to Search on Google for solution first – Which is good. But if not found then they give up. But so, less folks go ahead and try to see what is happening in Sitecore.Kernel/Any assembly. Because If you ask me what is Best Sitecore documentation then my answer will be “Reflector“. In my 6+ years crafting on Sitecore. Have fixed lot of issue or implemented lot of features using Reflector only! And you know How I started using it? On SDN Forum. John recommended lot of folks to check Reflector. And looking at my seniors who were expert in Sitecore. And they always relied in Reflector to understand any behavior!

So, as life’s secret lies in “The Secret” book🙂 Sitecore’s Secret lies in Sitecore’s assemblies and only Reflector can help you read it. So, would like to encourage all Sitecorians to start using Reflector. Earlier days I just used to open each class, method etc. To see what is lying inside? How Sitecore architect something this way? Why they did so? And during this exploration. I learnt Sitecore basics! And once you know Basics – Then it’s easy to become master of any technology “Every expert was once a beginner!”

In this blog, I would like to share some basics. And features I think are less/not used. But very powerful!

  1. Good starter links:
    1. https://www.simple-talk.com/dotnet/.net-tools/first-steps-with-.net-reflector/
    2. https://documentation.red-gate.com/display/REF8/.NET+Reflector+8+documentation
  2. Make sure all  your required Sitecore assemblies are loaded in reflector
  3. Search string or constant or Exact Match features are good to search any specific error message
  4. If you are searching for Class then make sure Search by Type (CTRL+T) is selected and for Method/Property/Field — Search by Member is selected – Very basic thing!
  5. If you would like to see Where some property/method/field/class is being used then you can use “Analyze” feature. Please refer “Analyze screen”
search-large

Reflector Search screen

Analyze

Analyze screen

Which one is your favorite trick. Which you think we all should know?

Thanks to all of those people who share this small tips and tricks with me!

Happy Coding!🙂

Follow

Get every new post delivered to your Inbox.

Join 116 other followers

%d bloggers like this: