一把umbraco AJAX调用不工作工作、umbraco、AJAX

2023-09-10 19:47:12 作者:斯文败类

我有,我已经安装了一把umbraco 6.1.6的NuGet package.Now我想打电话给使用jQuery的AJAX功能的视图控制器的MVC应用程序。该控制器被放置在MVC控制器的文件夹,它是继承与UmbracoApiController。我曾试图按照一把umbraco API文档,但每次我的要求是发送重定向404页。我曾尝试使用相同7.1.4一把umbraco从这里,它为我工作正常。任何人都可以提出一个解决方案,这一点。

I have a MVC application where I have installed umbraco 6.1.6 nuget package.Now I am trying to call a controller from a view using Jquery AJAX function. The controller is placed in MVC controller folder and it is inherited with UmbracoApiController. I have tried to follow the Umbraco API document ,But everytime my request is send it redirects to 404 page. I have tried the same using umbraco 7.1.4 downloaded from here and it works fine for me. Can anyone suggest a solution for this.

请求URL我用的是如下: - /一把umbraco / API / [ControllerName] / [ActionName] ,我也尝试过/一把umbraco / [YourAreaName] / [YourControllerName],但这太不适合我的工作。

The request url I have used is as follows :- /Umbraco/Api/[ControllerName]/[ActionName], I have also tried /Umbraco/[YourAreaName]/[YourControllerName] , but that too doesn't work for me.

推荐答案

检查不同的事情:

重新启动该网站(触摸web.config中) 你建立code吗?如果你把它放在APP_ code是它自动获取,否则你需要的DLL是在你的bin目录中。 在做什么在/ App_Data文件/日志日志文件告诉你吗? 您可以通过调用插入你自己的日志 LogHelper.Info&LT; MyClass的&GT;(一些信息) 你真的的真正的真的确定你没有忽略一些东西从文档? 你确定你的控制器从 UmbracoApiController 继承 有你尝试添加 [MemberAuthorize(AllowAll = TRUE)] 的API控制器或方法? reboot the site (touch the web.config) did you BUILD the code? If you put it in app_code is it picked up automatically, otherwise you need the DLL to be in your bin directory. what do the log files in /App_Data/Logs tell you? You can insert your own logs by invoking LogHelper.Info<myclass>("some message") are you really really really sure you have not overlooked something from the documentation? are you sure your controller inherits from UmbracoApiController have you tried adding [MemberAuthorize(AllowAll = true)] to the api controller or the method?

在code以下来自哪个我用在仪表板为最终用户一个用户控件。我想这是pretty的容易将其转换成剃刀宏。如果没有返回的事情,你做错了什么从上面的列表中。

The code below came from a usercontrol which i used in a dashboard for the end user. I guess it's pretty easy to convert it into a Razor macro. If this is not returning a thing, you did something wrong from the list above.

var requestHandler = HttpContext.Current.Request.RequestContext;
var urlHelper = new UrlHelper(requestHandler);
var actionlink = Umbraco.Web.UrlHelperExtensions.GetUmbracoApiService<MyApiController>(urlHelper, "MyMethodName");