ASMX:在运行时设置用户/密码
当我想连接到我的网络服务时如果我这样写:
m_TransferServiceSoap.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
它正在工作。但我需要一个登录表格。这样用户就可以输入他们的用户/通行证
,所以我正在创建一个 NetworkCredential 实例,并根据我从登录表单中获得的内容设置其用户/通行证成员,然后我不使用上面的行,而是编写了这一行:
m_TransferServiceSoap.Credentials = userpass; // the instance above.
但是以这种方式,当我调用该 webService 的方法,它给我错误。
设置凭据的方式是否错误?
When I want to connect to my web service If I write it like this:
m_TransferServiceSoap.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
it is working. but I need a Login Form. so users can enter their user/pass
so I am creating a NetworkCredential instance and setting its user/pass members from what I get from that login form and then instead of using the line above I am writing this one:
m_TransferServiceSoap.Credentials = userpass; // the instance above.
but in this way when I call a method of that webService, it gives me errors .
Is it the wrong way to set credentials?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在创建 NetworkCredential 时是否包含域名?
通话内容应如下所示:
我已将其添加为答案,以便如果有效,我可以提出要点...
帕特里克。
Are you including the domain name when you create your NetworkCredential?
the call should look something like this:
I've added this as an answer so that, if it worked, I can can the points...
Patrick.
这对我有用
this is what worked for me