请求的资源不支持 http 方法“GET”。
请求就报这个错,路由没有修改过。然后请求别的Api,就是找不到资源。。 控制器名称这些名字不会错的
iisexpress.exe Information: 0 : Response, Status=405 (MethodNotAllowed), Method=GET, Url=http://localhost:45457/api/user/, Message=“内容类型=“application/xml; charset=utf-8”,内容长度=未知”
你这个让别人怎么看
楼主。你的后台代码要开光吗?免费哦
不支持GET 肯定是POST 了啊,你看看API文档怎么解释的啊
我印象中,微博的API基本都是POSt
/// <summary> /// 获得用户信息 /// </summary> /// <param name="access_token">授权编号</param> /// <param name="uid">用户微博帐号</param> /// <returns></returns> public SinaUser GetSinaUserInfo(string access_token, string uid) { Stream outstream = null; Stream instream = null; StreamReader sr = null; HttpWebResponse response = null; HttpWebRequest request = null; Encoding encoding = Encoding.UTF8; try { request = (HttpWebRequest)WebRequest.Create("https://api.weibo.com/2/users/show.json?source ="+AppKey+"&access_token=" + access_token + "&uid=" + uid + ""); CookieContainer cookieContainer = new CookieContainer(); request.CookieContainer = cookieContainer; request.AllowAutoRedirect = true; request.Method = "GET"; request.ContentType = "application/x-www-form-urlencoded"; response = request.GetResponse() as HttpWebResponse; request.GetResponse(); instream = response.GetResponseStream(); sr = new StreamReader(instream, encoding); JsonTextParser parser = new JsonTextParser(); JsonObjectCollection obj = parser.Parse(sr.ReadToEnd().Replace("[]", "null")) as JsonObjectCollection; JsonUtility.GenerateIndentedJsonText = false; SinaUser model = new SinaUser(); model.Bi_followers_count = int.Parse(obj["bi_followers_count"].GetValue().ToString()); model.Blog = obj["url"].GetValue().ToString(); model.Description = obj["description"].GetValue().ToString(); model.Domain = obj["domain"].GetValue().ToString(); model.Favourites_count = int.Parse(obj["favourites_count"].GetValue().ToString()); model.Followers_count = int.Parse(obj["followers_count"].GetValue().ToString()); model.Friends_count = int.Parse(obj["friends_count"].GetValue().ToString()); string gender = obj["gender"].GetValue().ToString(); model.Gender = gender == "m" ? "男" : "女"; model.ImageUrl = obj["avatar_large"].GetValue().ToString(); model.Name = obj["screen_name"].GetValue().ToString(); model.Place = obj["location"].GetValue().ToString(); model.Profile_url = obj["profile_url"].GetValue().ToString(); model.Statuses_count = int.Parse(obj["statuses_count"].GetValue().ToString()); model.Uid = obj["id"].GetValue().ToString(); model.Verified = bool.Parse(obj["verified"].GetValue().ToString()); model.Verified_reason = obj["verified_reason"].GetValue().ToString(); model.AccessToken = access_token; if (model != null) { return model; } return null; } catch(Exception ex) { return null; } }