Hot answers tagged

8 votes
Accepted

How do I access Sitecore.Context.Item in normal MVC Controller

If it's an ajax call you just did from javascript to a normal MVC controller, there is no Sitecore.Context.Item there. What you can do is in your original Sitecore rendering write the id of your item ...
user avatar
6 votes
Accepted

Why is my Ajax url not recognizing my sitecore controller or hitting my breakpoint in my sitecore controller?

It's worth mentioning that the route in the question is called out in a setting. The comment above Mvc.IllegalRoutes explains itself a bit. <!-- MVC: Pipe separated list of route URL's that are ...
user avatar
  • 2,457
4 votes

Why is my Ajax url not recognizing my sitecore controller or hitting my breakpoint in my sitecore controller?

First off, @PatrickBarron is absolutely correct about your route. However, there is one other issue that I see. Have you tried dropping the word "Controller" off the name of your controller when ...
user avatar
4 votes

How do I redirect to another item in Sitecore

You cannot redirect from an AJAX post. You could return the URL you want to redirect and redirect from Javascript. success: function(response){ window.location.href = response; }
user avatar
  • 126
3 votes
Accepted

Sitecore Ajax post returning same page

From my point of view it's not a correct way for call your api. Try to sent your request in another way: instead of window.location.href try to call http://{hostname}/api/sitecore/BlogVotes/test via ...
user avatar
3 votes

NullReferenceError for Html.Sitecore().Rendering in Ajax Calls

I found the solution @Html.Sitecore().Rendering() will not work for View rendering type. My rendering was of type View rendering which it was throwing above error. And also I tried with @Html....
user avatar
  • 61
3 votes

Why is my Ajax url found when I test in preview mode, but not when I bring up the page in a url I get not found errors

I would recommend creating a custom route for Ajax functionality that doesn't reside in the Sitecore Shell. From my understanding, using the default route of /api/Sitecore only works if you are logged ...
user avatar
  • 4,259
3 votes

Ajax Begin Form Api Route is different in 10.1

Set "IsCxaSite" to true in "Site Grouping" item for that SXA site and then try to trigger cxa api's.
user avatar
  • 370
2 votes

How do I access Sitecore.Context.Item in normal MVC Controller

In Ajax requests the Sitecore.Context.Item object is NULL. So you can't use it to get the current page. To work around this, you will need to tell the MVC action what the current context item is ...
user avatar
  • 1,632
1 vote

How do I redirect to another item in Sitecore

The response from Controller should be JsonResult, in which you can define the Url that you want to redirect. new Json { newurl = link }; Then in the success method of ajax, you can do window....
user avatar
  • 123
1 vote

Why is my Ajax url not recognizing my sitecore controller or hitting my breakpoint in my sitecore controller?

In sitecore MVC always use /api/Sitecore/{controller}/{action}. It should work if you are call from ajax. Sample code: jQuery.ajax({ type: "POST", url: "/api/sitecore/{...
user avatar
  • 91
1 vote

Why is my Ajax url not recognizing my sitecore controller or hitting my breakpoint in my sitecore controller?

It looks like the URL you are sending the request to doesn't match your route configuration. Your URL is /Website/Controllers/FindAnAffiliateController/getAffiliate and your rout is {controller}/{...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible