c# – 为什么在ASP.NET中调用API仅在我有Fiddler打开的情况下工
发布时间:2020-12-15 04:12:06 所属栏目:百科 来源:网络整理
导读:我正在这样调用我的索引控制器中的API,一切都正常,只有当我有Fiddler打开的时候. public ActionResult Index(){ Base model = null; var client = new HttpClient(); var task = client.GetAsync( "http://example.api.com/users/john/profile") .ContinueWi
我正在这样调用我的索引控制器中的API,一切都正常,只有当我有Fiddler打开的时候.
public ActionResult Index() { Base model = null; var client = new HttpClient(); var task = client.GetAsync( "http://example.api.com/users/john/profile") .ContinueWith((taskwithresponse) => { var response = taskwithresponse.Result; var readtask = response.Content.ReadAsAsync<Base>(); readtask.Wait(); model = readtask.Result; }); task.Wait(); return View(model); } 如果我关闭Fiddler我得到以下错误:
是否有一些配置我必须包括,所以调用一个API的工作,即使我没有Fiddler打开. 解决方法
检查任何代理配置的web.config,并检查您是否配置了.net可能使用的系统默认代理.
您可以将其添加到您的web.config以禁用代理配置: <system.net> <!-- set enabled to true to use the system default proxy --> <defaultProxy enabled="false" /> </system.net> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |