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 ...
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 ...
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 ...
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;
}
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 ...
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....
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 ...
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.
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 ...
1
vote
Accepted
Sitecore Forms: Ajax is working on some pages but not on others for same form
This error comes when you doesn't include the following scripts in your Layout file. Here are these scripts.
@Html.RenderFormStyles()
@Html.RenderFormScripts()
So the error is happening because you ...
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....
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/{...
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}/{...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
ajax × 21mvc × 5
sitecore-api × 4
javascript × 4
mvc-forms × 3
sitecore-forms × 2
sitecore-client × 1
sitecore-commerce × 1
experience-editor × 1
wffm × 1
presentation × 1
webapi × 1
redirect × 1
components × 1
webforms × 1
routing × 1
sitecore-mvc × 1