Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • mohammed 17 posts 88 karma points
    Mar 15, 2015 @ 16:01
    mohammed
    0

    Cannot find the Umbraco route definition in the route values, the request must be made in the context of an Umbraco request

    Hi,

    I am currently having issues wtih Redirecting in Umbraco. On my register page, I am allowing users to get their details from Facebook and then I want to reload the page with the details from Facebook. 

    The action that I use to load the page is: 

      [ChildActionOnly]

            public ActionResult ShowRegisterFreelancer(RegisterFreelancer freelancerModel, string returnUrl)

            {

                //So that the user can be referred back to where they were when they click logon

                if (string.IsNullOrEmpty(returnUrl) && Request.UrlReferrer != null)

                    returnUrl = Server.UrlEncode(Request.UrlReferrer.PathAndQuery);

                //UmbracoContext.UrlProvider.GetUrl

                if (Url.IsLocalUrl(returnUrl) && !string.IsNullOrEmpty(returnUrl))

                {

                    ViewBag.ReturnURL = returnUrl;

                }

                MVCUmbracoFreelance.Models.RegisterFreelancer model = new RegisterFreelancer();

                if (freelancerModel != null)

                {

                    model.Cellphone = freelancerModel.Cellphone;

                    model.ConfirmPassword = freelancerModel.ConfirmPassword;

                    model.EmailAddress = freelancerModel.EmailAddress;

                    model.FirstName = freelancerModel.FirstName;

                    model.Password = freelancerModel.Password;

                    model.Surname = freelancerModel.Surname;

                }

                return PartialView("RegisterFreelancer", model);

            }

     

    Then if the user chooses Facebook, I use an action to get the users details from Facebook:

           public ActionResult FacebookCallback(string code)

            {

                if (code == null)

                {

                    code = Request.Form.GetValues("accessToken").First();

                }

                FacebookClient fb = new FacebookClient(code);

                var result2 = fb.Get("me?fields=first_name,middle_name,last_name,id,email");

                JObject Job = JObject.Parse(result2.ToString());

                JToken Jdata = Job.Root;

                MVCUmbracoFreelance.Models.RegisterFreelancer model = new RegisterFreelancer();

                if (Jdata.HasValues)

                {

                    model.FacebookID = (string)Jdata.SelectToken("id");

                    model.FirstName = (string)Jdata.SelectToken("first_name");

                    model.Surname = (string)Jdata.SelectToken("last_name");

                   // Response.Write(UID + “-” + firstname + “-” + lastname);

                }

                return RedirectToCurrentUmbracoPage(); //this is where it breaks

     

            }

     

    Can someone please help me with this, I am trying to reload the page with all the details of the user from facebook? 

    Thanks 

  • Alex Skrypnyk 6175 posts 24176 karma points MVP 8x admin c-trib
    Mar 16, 2015 @ 02:00
    Alex Skrypnyk
    100

    Hi Mohammed,

    Problem is that you trying to redirect ajax call. Try to use javascript redirect instead :

    return JavaScript("window.location = " + CurrentPage.Url + ";");

    Thanks

  • mohammed 17 posts 88 karma points
    Mar 16, 2015 @ 07:43
    mohammed
    0

    Hi Alex,

     

    Thanks for the reply. Will give that a try and feedback.

     

  • mohammed 17 posts 88 karma points
    Mar 17, 2015 @ 17:13
    mohammed
    0

    Hey Alex, 

    u r a star. thanks man, the javascript worked like a charm

Please Sign in or register to post replies

Write your reply to:

Draft