【问题标题】:I'm Getting an error "Endpoint Error: MethodNotAllowed" in ASP.Net MVC我在 ASP.Net MVC 中收到错误“端点错误:MethodNotAllowed”
【发布时间】:2017-02-28 18:02:03
【问题描述】:

每次我去这个视图时,我都会在从沙盒应用程序中获取客户列表时遇到这个错误。我正在使用 PaysimpleSDK https://github.com/PaySimple/PaySimpleSDK/wiki/Customer-Service

我的错误

说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:PaySimpleSdk.Exceptions.PaySimpleEndpointException:端点错误:MethodNotAllowed:

var customers = await customerService.GetCustomersAsync(CustomerSort.FirstName);

这是我的控制器

  public async Task<ActionResult> Trial()
    {
        string username = "myusername";
        string apiKey = "apikey";
        string baseUrl = "https://sandbox-api.paysimple.com/v4/customer";
        var settings = new PaySimpleSettings( apiKey, username, baseUrl );
        

        var customerService = new CustomerService(settings);
        var customers = await customerService.GetCustomersAsync();

        return View(customers.ToString());
    }

我的视图(我无法复制整个视图代码,因为它有一个表格)

@model IEnumerable<PaySimpleSdk.Customers.Customer>
@{
ViewBag.Title = "Index";
}

 @Html.DisplayNameFor(model => model.FirstName)
 @foreach (var item in Model)
 @Html.DisplayFor(modelItem => item.FirstName)






   

【问题讨论】:

  • 如果你调试,错误出现在这一行:customerService.GetCustomersAsync(); 或者它甚至没有进入Trial() 动作?还是别的地方?
  • 看来您正在调用一个带有 http 动词(post, put, get...) 的方法不是该方法所期望的
  • @Alisson 出现错误,当我进入试用版时
  • @GhiniAntonio 我没有 http 动词
  • 这个异常来自他们的库,所以我们根本帮不上忙。在their documentation 中查看您正在获取的PaySimpleEndpointException

标签: c# asp.net asp.net-mvc paysimple


【解决方案1】:

在 mvc 中,当我使用 http get 调用操作并且该操作已被声明为仅服务于 http 帖子时,或者通常当您为特定动词声明了操作并且您尝试使用未使用的操作时,我通常会收到此错误允许

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-31
  • 2018-11-01
  • 2019-01-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多