即时通讯使用一个api有些api给出了禁止错误403.如何检查webrequest的状态代码
错误 System.Net.WebException:'远程服务器返回错误:(403)Forbidden。'
var assetTracker = new AssetTracker { deviceid = deviceID };
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("url");
req.Method = "GET";
req.Headers["Authorization"] = "Basic " + "QzdBQ";
req.ContentType = "application/vnd.onem2m-res+json";
req.Accept = "application/vnd.onem2m-res+json;";
req.Headers["Cache-Control"] = "no-cache";
req.Headers["X-M2M-RI"] = "99000";
req.Headers["X-M2M-Origin"] = "C7AAC";
// Here I need to check the status code
HttpWebResponse resp = req.GetResponse() as HttpWebResponse;//getting error