API Questions on Kentico API.
Version 6.x > API > User Registration QueryString View modes: 
User avatar
Member
Member
CJB - 1/10/2012 3:14:57 AM
   
User Registration QueryString
I am trying to perform some updates to a 3rd party system after a user has registered in Kentico. I am using the ObjectEvents.Insert.After event to perform these updates.

I need to get hold of the QueryString that was used to navigate to the registration page as the 3rd party system is using this to pass various information such as a referrer id etc. Is this possible?

Thanks
Craig Bennett

User avatar
Member
Member
kentico_michal - 1/10/2012 7:55:39 AM
   
RE:User Registration QueryString
Hello,

You can user the UserInfo.UserURLReferrer property to get the URL Referrer of a newly registered user.

Best regards,
Michal Legen

User avatar
Member
Member
CJB - 1/10/2012 8:58:02 AM
   
RE:User Registration QueryString
Michal

Thanks but that only gives me the url of the referrer. I need the query string that the user used to navigate to the registration page so that I can get each of the parameters. If possible I would like to access this from within the ObjectEvents.Insert.After event.

An example would be:

http://cms.mydomain.com/Register.aspx?ReferrerId=5a853a99fde34fbfb8872b10ca5420a5&User=username

Thanks
Craig


User avatar
Member
Member
kentico_michal - 1/11/2012 2:04:50 AM
   
RE:User Registration QueryString
Hello Craig,

The query parameters are removed in the ProcessReferrer method (~\App_Code\Application\CMSAppBase.cs) using the following code:

string path = URLHelper.RemoveQuery(referrer.AbsoluteUri);

// Save the referrer value
CMSContext.CurrentUser.URLReferrer = path;

However, it is not recommended to modify it. You can instead take the referrer.AbsoluteUri property and save it, for example, to a new cookie:

CookieHelper.SetValue("UrlReferrerWithQueryParams", referrer.AbsoluteUri, DateTime.Now.AddDays(1));

You can do so in the ProcessReferrer method.

Then you should be able to access this value in the ObjectEvents.Insert.After event with the help of this code:

string urlReferrerWithQueryParams = CookieHelper.GetValue("UrlReferrerWithQueryParams");

Best regards,
Michal Legen

User avatar
Member
Member
CJB - 1/11/2012 8:13:53 AM
   
RE:User Registration QueryString
Michal

Thanks. This is not quite what I needed but has helped me identify where I can get the QueryString. Initially I added the following to the ProcessReferrer method.

CookieHelper.SetValue("UrlWithQueryParams", HttpContext.Current.Request.Url.AbsoluteUri, DateTime.Now.AddDays(1));


After that I tried adding the same code to the CMSSessionEvents.Start.After event, meaning that I do not have to alter the standard CMSAppBase.cs code.

Thanks for your help.
Craig