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)
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
Hi Mohammed,
Problem is that you trying to redirect ajax call. Try to use javascript redirect instead :
return JavaScript("window.location = " + CurrentPage.Url + ";");
Thanks
Hi Alex,
Thanks for the reply. Will give that a try and feedback.
Hey Alex,
u r a star. thanks man, the javascript worked like a charm
is working on a reply...