服务器返回错误405方法不允许

时间:2017-04-03 17:19:48

标签: c#

每当我打电话给getLatestCustomerNumber()程序时,有人可以告诉我 它抛出了一个不允许的方法的例外。

用户已注册

public ActionResult UserRegistration(Customer customer, FormCollection fc)
    {
        try
        {
            var newCustomerNo = "";
            string latestCustomerNo = _com.GetLatestCustomerNo();//this function would b called
            if (latestCustomerNo == null)
            {
                newCustomerNo = "PBC-" + "000001";
            }
            else
            {
                var incrementalPart = latestCustomerNo.Substring(0, 4);
            }

之后

public string GetLatestCustomerNo()
{
        try
        {
            string result = GetStructure(String.Format("GetLatestCustomerNo"));//this get structure would be called
            return JsonConvert.DeserializeObject<string>(result);

        }
        catch (Exception ex)
        {
            return "Error";
        }

}



public string GetStructure(string uri)
{
        string _result = "False";
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(String.Format("{0}/{1}", baseAddress, uri));
    req.Method = "GET";
    req.ContentType = "application/json";
    using (HttpWebResponse res = (HttpWebResponse)req.GetResponse())
    {
        using (StreamReader sr1 = new StreamReader(res.GetResponseStream()))
        {
            _result = sr1.ReadToEnd();
        }
    }
    return _result;
}

现在问题是webhttpResponse没有从服务器获取,它会引发异常

0 个答案:

没有答案