在ASP.NET webapp中,我为.axd页面定义了一个自定义处理程序:
<system.webServer>
<handlers>
<add verb="*" path="*.axd" name="MyAXDHandler" type="MyAXDHandler"/>
</handlers>
...
</system.webServer>
然后,我可以通过浏览器(Chrome,如果重要)成功点击http://localhost/somename.axd等网址。但是,代码如
var request = WebRequest.CreateHttp("http://localhost/somename.axd");
request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
request.CookieContainer = new CookieContainer();
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36";
var response = request.GetResponse())
因WebException(StatusCode 404)而失败,并且使用像wget这样的工具也失败了404.
发生了什么事?我该如何解决?