November Happy Hour will be moved to Thursday December 5th.

url path to hit the controller method in jquery

Vote:
 

Model PageType:SamplePage.cs
public virtual XhtmlString MainBody { get; set; }

Controller: SamplePageController.cs
public ActionResult Index(SamplePage currentPage)
{

PageViewModel model = new PageViewModel(currentPage);
return View(model);

}

public ActionResult Getresult(string sector)
{
List data = new List(Getvalues());
var objList = data.Where(a => a.Sector == sector).ToList();

return Json(objList, JsonRequestBehavior.AllowGet);
}

Index.cshtml
@model EPiServerSite1.Models.ViewModels.PageViewModel


When I created the page, I could see the options listed above on the page.

Based on the selection of item, I would need to call the 'Getresult' in the controller, the following script is working fine in a normal MVC
application, but the controller method(Getresult) is not hit in the episerver site when I put a breakpoint. Is the url path in EPiServer not the same
as we write in MVC?
What's the path to be entered in the jquery url to hit the action in controller in EPiServer?

#113333
Nov 18, 2014 15:39
Vote:
 

This is an interesting subject so I did a quick search.

I found this post : Rest Service

Maybe it will help

#113344
Edited, Nov 18, 2014 17:04
Vote:
 

This has got solved as below

var MyAppUrlSettings = {
MyUsefulUrl: '@Url.Action("Getresult","SamplePage")'

 $.ajax({

            url: MyAppUrlSettings.MyUsefulUrl,  

            ............

#113352
Edited, Nov 19, 2014 0:29
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.