我在ASP.Net MVC

时间:2017-02-28 18:02:04

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

每次我要访问此视图时,我从沙盒ap中获取客户列表时遇到此错误。我正在使用PaysimpleSDK https://github.com/PaySimple/PaySimpleSDK/wiki/Customer-Service

我的错误

  

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

     

异常详细信息:PaySimpleSdk.Exceptions.PaySimpleEndpointException:Endpoint Error: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)

1 个答案:

答案 0 :(得分:0)

在mvc中我通常会在使用http get调用操作时出现此错误,并且已声明该操作仅用于http post或者通常在您为特定谓词声明操作时,并且您尝试使用允许