Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc MVC URL的webRequest_Asp.net Mvc_Httpwebrequest_Httpwebresponse - Fatal编程技术网

Asp.net mvc MVC URL的webRequest

Asp.net mvc MVC URL的webRequest,asp.net-mvc,httpwebrequest,httpwebresponse,Asp.net Mvc,Httpwebrequest,Httpwebresponse,我正在使用下面的代码从一些网站获取我的数据 HttpWebRequest-webRequest=(HttpWebRequest)webRequest.Create(URL); HttpWebResponse webResponse=(HttpWebResponse)webRequest.GetResponse() 当URL指向某个pdf页面时,我成功地获取了数据,但当我使用MVC项目URL尝试上述代码时ex:http://domain.com/controller/action?paramete

我正在使用下面的代码从一些网站获取我的数据

HttpWebRequest-webRequest=(HttpWebRequest)webRequest.Create(URL);
HttpWebResponse webResponse=(HttpWebResponse)webRequest.GetResponse()

当URL指向某个pdf页面时,我成功地获取了数据,但当我使用MVC项目URL尝试上述代码时
ex:http://domain.com/controller/action?parameter=xyz
,我得到404错误。我的假设是
参数
零件在请求数据时被忽略,因此我得到
页面未找到
状态

我可以在浏览器中访问路径,但在使用webRequest时出错


以前有人遇到过这个问题吗?

可能您试图获取的操作被标记为HttpPost。如果是,这两行之间的代码应该可以解决问题:

webRequest.Method = "POST";