Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > CMSDesk Site Selector problem View modes: 
User avatar
Member
Member
robert-tailor.co - 8/14/2012 4:40:43 PM
   
CMSDesk Site Selector problem
The drop down list to switch to a different site at the top of the CMSDesk interface seems to have a bug.

I have 4 Kentico websites. 2 of them are on different domains, and another 2 are in virtual directories on one domain. E.g.:

my.website.com
my.website.com.au
my.website.com.au/site1
my.website.com.au/site2

If I use CMSDesk on the sites in a virtual directory (e.g. my.website.com.au/site1 or my.website.com.au/site2 above) and then select to switch to a different site (e.g. my.website.com), Kentico tries to re-use the same path and so it takes me to my.website.com/site1 - which doesn't exist.

How can I change the behaviour of the site selector to always take the user to the CMSDesk root of the selected website?

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 8/14/2012 7:34:04 PM
   
RE:CMSDesk Site Selector problem
Sorry man, I don't think you can change it like that. You can suggest a feature for the next version on kentico.uservoice.com though

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/18/2012 5:07:46 PM
   
RE:CMSDesk Site Selector problem
Hi,

you can still use API to authenticate user:
Single sign on

Best regards,
Ivana Tomanickova

User avatar
Member
Member
robert-tailor.co - 8/20/2012 4:20:09 PM
   
RE:CMSDesk Site Selector problem
kentico_ivanat wrote: Hi,

you can still use API to authenticate user:
Single sign on

Best regards,
Ivana Tomanickova

Hi Ivana,

I think you misunderstand the problem. Enabling Single Sign on in the API will not fix this issue. The problem is that Kentico is not using the Site Domain Name specified in the list of sites as the base URL for CMSDesk. This seems like a bug to me.

The site selector drop down list at the top of the CMSDesk page does not go to the CMSDesk login for the relevant sites.

As I described in my example, if I am viewing the CMSDesk for my.website.com.au/site1, and then use the site selector to view the CMSDesk for my.website.com, Kentico tries to take me to my.website.com/site1 (which doesn't exist).

Using the site selector:

Going from my.website.com/CMSDesk to my.website.co.nz/CMSDesk works fine.
Going from my.website.co.nz/CMSDesk to my.website.com.au/site1/CMSDesk works fine.
Going from my.website.com.au/site1/CMSDesk to my.website.co.nz/CMSDesk does not work. Instead, I am taken to my.website.co.nz/site1/CMSDesk (which doesn't exist).

Please try it for yourself and let me know what you find.

Rob.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/22/2012 4:21:07 PM
   
RE:CMSDesk Site Selector problem
Hi,

I checked this with our developer and this behavior is "by design".

We are supporting virtual directories without the specification of the directory e.g. localhost domain name can be use for any virtual directory under the domain localhost.

It means that we don't know if current virtual directory should be used or not (we always use current virtual directory if it is not specified in site domain name)

Best regards,
Ivana Tomanickova

User avatar
Member
Member
robert-tailor.co - 8/22/2012 6:02:23 PM
   
RE:CMSDesk Site Selector problem
kentico_ivanat wrote: We are supporting virtual directories without the specification of the directory e.g. localhost domain name can be use for any virtual directory under the domain localhost.

It means that we don't know if current virtual directory should be used or not (we always use current virtual directory if it is not specified in site domain name)

Hmmm...this leaves my client with a problem. I was advised to use virtual directories to represent each website in different regions, but a content editor cannot switch between websites on virtual directories and websites on domain roots. Essentially, the site selector drop down list is going to cause an error whenever they select a site on a different domain that is not hosted in a virtual directory.

Can your developers suggest any way around this?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/25/2012 7:35:04 PM
   
RE:CMSDesk Site Selector problem
Hi,

I discussed this with our developer and it seems that you will need implement this by custom code and set tell that this particular domain is without virtual directory (I will provide you more details if second option will not work).

Or you can try to change domain name in the Site Manager - Sites - edit some site - and change site domain name from for example localhost to localhost/

I could do the trick.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
robert-tailor.co - 8/26/2012 4:34:50 PM
   
RE:CMSDesk Site Selector problem
kentico_ivanat wrote: Hi,

I discussed this with our developer and it seems that you will need implement this by custom code and set tell that this particular domain is without virtual directory (I will provide you more details if second option will not work).

Or you can try to change domain name in the Site Manager - Sites - edit some site - and change site domain name from for example localhost to localhost/

I could do the trick.

Best regards,
Ivana Tomanickova

Hi Ivana,

All the ~/site1 and ~/site2 sites are listed in IIS as Applications under the main domain. Does Kentico always assume they are virtual directories?

I took your suggestion of appending each of these sites with a slash in 'Site Manager' -> 'Sites' -> 'Site Domain Name'. e.g.:

my.website.com
my.website.com.au
my.website.com.au/site1/
my.website.com.au/site2/

but that really confuses Kentico, and the sites will not load properly. My code behind relies on CMSContext.CurrentSiteName in parts, and this is always returning the name of the main domain, not the 'sub' sites under that domain.

So it looks like I have to write custom code to get the site selector working. Can your developers suggest some code to get this working, as I am not very familiar with inner workings of Kentico's CMSDesk?

Thanks!

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/31/2012 5:43:24 PM
   
RE:CMSDesk Site Selector problem
Hi,

you need to authenticate user using API in the file:
\CMSDesk\Header.aspx.cs

There is an event handler SiteSelector_OnSelectionChanged, where you need to place the code.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
robert-tailor.co - 9/3/2012 5:53:57 PM
   
RE:CMSDesk Site Selector problem
kentico_ivanat wrote: Hi,

you need to authenticate user using API in the file:
\CMSDesk\Header.aspx.cs

There is an event handler SiteSelector_OnSelectionChanged, where you need to place the code.


I've looked into this in more detail and tried switching from 'my.website.com.au/site1' to 'my.website.com'.

The problem originates from line 298 in '\CMSDesk\Header.aspx.cs':

url = URLHelper.GetAbsoluteUrl(url, domain, null, null);


The GetAbsoluteUrl does not appear to resolve the URL properly from the given parameters. It's a compiled library, so I cannot see it's source. However, the supplied parameters are as follows:

url: '~/CMSDesk/Default.aspx'
domain: 'my.website.com'

This *should* resolve to 'http://my.website.com/CMSDesk/Default.aspx'.

But it doesn't. Instead, it resolves to 'http://my.website.com/site1/CMSDesk/Default.aspx'

It looks like URLHelper.GetAbsoluteUrl() is using the current website's setup to generate absolute paths, when it *should* be using the target website's setup to generate absolute paths (in case the target website is a virtual application or root application).

I have modified the SiteSelector_OnSelectionChanged() code to the following:

url = url.StartsWith("~") ? domain + url.Substring(1) : domain + url;

if (!URLHelper.ContainsProtocol(url))
url = "http://" + url;


Unfortunately, this will get overwritten every time I perform a site upgrade. Can you suggest any workarounds to this?

Also, can you foresee any problems with the replacement code?

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 9/11/2012 3:28:29 AM
   
RE:CMSDesk Site Selector problem
Hi Robert,

The GetAbsoluteUrl method really uses a current application path (HttpRuntime.AppDomainAppVirtualPath). It is by design behavior.

Regarding your code, I would recommend a very similar code:

url = domain.TrimEnd('/') + url.TrimStart('~');

if (!URLHelper.ContainsProtocol(url))
{
// Add protocol
if ((HttpContext.Current == null) || !IsSSL)
{
// ... add http://
url = "http://" + url;
}
else
{
// ... add https://
url = "https://" + url;
}
}

The Upgrade process (when using Kentico Installation Manager) will warn you about changed files that you need to merge manually when upgrading from version 6. You can see the same system when hotfixing. It will not re-write your changes.


Best regards,
Helena Grulichova


User avatar
Member
Member
robert-tailor.co - 9/11/2012 3:00:52 PM
   
RE:CMSDesk Site Selector problem
kentico_helenag wrote: Hi Robert,

The GetAbsoluteUrl method really uses a current application path (HttpRuntime.AppDomainAppVirtualPath). It is by design behavior.

Regarding your code, I would recommend a very similar code:

url = domain.TrimEnd('/') + url.TrimStart('~');

if (!URLHelper.ContainsProtocol(url))
{
// Add protocol
if ((HttpContext.Current == null) || !IsSSL)
{
// ... add http://
url = "http://" + url;
}
else
{
// ... add https://
url = "https://" + url;
}
}

The Upgrade process (when using Kentico Installation Manager) will warn you about changed files that you need to merge manually when upgrading from version 6. You can see the same system when hotfixing. It will not re-write your changes.


Best regards,
Helena Grulichova


Thanks Helena,

Just a note - the IsSSL value used in your example is in the URLHelper class. So that line should read:

if ((HttpContext.Current == null) || !URLHelper.IsSSL)


Thanks again,

Rob.

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 9/12/2012 2:57:29 AM
   
RE:CMSDesk Site Selector problem
Hi Rob,


you are right. I took the code from the URLHelper class and the IsSSL property was defined there directly so it was not necessary to specify the class. If you use the code anywhere else, it is needful to add the class. Thank you.


Best regards,
Helena Grulichova