0

我最近将我的代码从 4.7.1 移到了 4.11.10。在旧版本中,rest 扩展曾经完美地工作。但在 4.11.10 中它不起作用,我收到 500 错误。甚至调试也没有打到那里。

其余方法的 URLhttp://localhost/Base/Landing/GetCountries/3

注意:- 我没有升级 umbraco。我只是在安装后将我的代码移动到更高版本

下面是代码片段

namespace Test.Umbraco.Ajax
{

[RestExtensionAttribute("Landing")]
public class Landing : Core.AjaxBase
{

    [RestExtensionMethodAttribute]
    public static string GetCountries()
    {
        return Core.RazorRenderer.RenderScriptFile("LandingPage/GetCountries", 0, GetLandingParameters(false));
    }
}
4

1 回答 1

0

很可能您的代码正在引发异常,这将转换为 500 错误来掩盖它。所以问题可能是任何事情。我遇到了同样的问题,我做的最好的事情是将所有代码包装在 try/catch 中,并将异常作为字符串返回。请记住,为了从异常中获取所有信息,您需要在调试模式下编译并将 .pdb 文件与 .dll 一起复制。

...

[RestExtensionMethodAttribute]
public static string GetCountries() {
 try {
  return Core.RazorRenderer.RenderScriptFile("LandingPage/GetCountries", 0, GetLandingParameters(false));
 } catch (Exception e) {
   return e.ToString();
 }
}

...

希望这可以帮助您找到问题!它对我有用。

于 2014-01-24T22:10:52.903 回答