我正在尝试访问此页面: http://tawn.tnau.ac.in/General/BlockWiseSummaryPublicUI.aspx?EntityHierarchyOneKey=1&lang=en 代码如下:
String strResult;
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(strURL);
objResponse = objRequest.GetResponse();
// the using keyword will automatically dispose the object
// once complete
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
strResult = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
访问其他页面时工作正常。我尝试使用 Mozila 访问此页面,但在 Chrome 上运行时无法访问。
请让我知道解决方案。
提前致谢
最佳答案
问题与浏览器无关。你的代码应该可以正常工作。但是,当您提出请求时,您可能需要提供一些凭据才能访问该页面。
如果您不提供凭据,请求通常会被重定向到一个页面,这就是您的情况。
关于c# - 无法使用 WebResponse c# 访问此页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20628206/