是否有一段不错且经过测试的代码可以用于此目的:
获取用户/通行证和 Web 服务的地址(asmx 页面)并检查用户/通行证是否有效。
我认为我应该使用 HTTPRequest 等来做到这一点,但我对该主题没有很好的了解,导致我当前的方法无法正常工作。
如果有一段很好的代码用于此目的,我很感激您向我指出这一点。
谢谢
PS:我没有在我的代码中使用 DefaultCredentials。因为我希望他们输入用户/通行证,所以现在我需要能够测试他们的用户/通行证,并在他们的凭据无效时向他们显示正确的消息。
Is there a nice and tested piece of code out there that I can use for this purpose:
get the user/pass and the address of a web service (asmx page) and check if the user/pass are valid or not.
I think I should use HTTPRequest,etc to do that but I do not have a good knowledge on that topic , causing my current method to not working properly.
If there is a good piece of code for this purpose I appreciate for pointing me to that.
Thanks
P.S: I am not using DefaultCredentials in my code. Since I want them to enter user/pass so now I need to be able to TEST their user/pass and show proper message to them if their credentials is not valid.
发布评论
评论(2)
您可以使用 HttpWebRequest。凭据属性(取决于 Web 服务身份验证)和 CredentialCache 类。
还有一些代码示例(来自谷歌):
检索 .NET 中的 HTTP 内容
结合 调用Web 服务动态使用 HttpWebRequest 和
.Credentials
。You can use the HttpWebRequest.Credentials Property (depends on the web service authentication) and the CredentialCache Class.
Also some code examples (from google):
Retrieving HTTP content in .NET
Combine Invoking Web Service dynamically using HttpWebRequest with
.Credentials
.