无法将类型为"System.Net.FileWebRequest"的对象转换为类型为"System.Net.HttpWebRequest"的对象. [英] Unable to cast object of type 'System.Net.FileWebRequest' to type 'System.Net.HttpWebRequest'.

查看:1250
本文介绍了无法将类型为"System.Net.FileWebRequest"的对象转换为类型为"System.Net.HttpWebRequest"的对象.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我从服务器尝试时遇到了以上错误(在服务器上部署了相同的代码). 但是,当我尝试从本地计算机上使用相同的代码时,它不会给出错误.

Hi Guys I'm getting the above error when tryin from a server(deployed the same code on the server). But when I'm tryin to use the same code from my local machine, it is not giving error.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);

任何有想法的人怎么了?

Any idea guys what could be wrong?

推荐答案

传入的URI并非http URI,而只是路径或file URI.确保URI以http:开头.如果它是相对URI,则需要将其设为绝对.

The URI being passed in is not an http URI -- it's either just a path or a file URI. Ensure the URI starts with http:. If it's a relative URI, you'll need to make it absolute.

这篇关于无法将类型为"System.Net.FileWebRequest"的对象转换为类型为"System.Net.HttpWebRequest"的对象.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆