在我们的应用中有一些类型的在线帮助。它的工作原理很简单:如果用户点击帮助按钮的URL是构建依赖于当前的语言和帮助上下文(如http://example.com/help/+ LANG_ID] +[HELP_CONTEXT])和所谓在浏览器中。
in our application we have some kind of online help. It works really simple: If the user clicks on the help button a URL is build depending on the current language and help context (e.g. "http://example.com/help/" + [LANG_ID] + "[HELP_CONTEXT]) and called within the browser.
所以我的问题是:我如何检查文件是否存在Web服务器上,而无需加载整个文件内容
So my question is: How can i check if a file exists on the web server without loading the complete file content?
感谢您的帮助!
更新:感谢您的帮助。我的问题已经回答。 现在我们有代理认证问题的一个无法发送HTTP请求;)
Update: Thanks for your help. My question has been answered. Now we have proxy authentication problems an cannot send the HTTP request ;)
推荐答案
您可以使用.NET做一个HEAD请求,然后看一下响应的状态。
You can use .NET to do a HEAD request and then look at the status of the response.
您code会是这个样子(摘自The卑微的HTTP HEAD请求):
Your code would look something like this (adapted from The Lowly HTTP HEAD Request):
// create the request
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
// instruct the server to return headers only
request.Method = "HEAD";
// make the connection
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
// get the status code
HttpStatusCode status = response.StatusCode;
下面是一个清单,详细说明状态codeS 的可以通过状态code枚举返回。
Here's a list detailing the status codes that can be returned by the StatusCode enumerator.
相关推荐
最新文章