ASMX:在运行时设置用户/密码 [英] ASMX: Setting User/Password at run-time
问题描述
当我想连接到我的Web服务时如果我这样写:
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
所以我要创建一个NetworkCredential实例并根据从该登录表单获得的内容来设置其用户/密码成员,然后而不是使用上面的行来编写该实例:
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.
但是以这种方式,当我调用该webService的方法时,它给了我错误.
but in this way when I call a method of that webService, it gives me errors .
设置凭据的方式是否错误?
Is it the wrong way to set credentials?
推荐答案
创建NetworkCredential时是否包括域名?
Are you including the domain name when you create your NetworkCredential?
该呼叫应如下所示:
var nc = new NetworkCredential( "Name","Password","Domain Name");
我已将此添加为答案,因此,如果可行,我可以指出要点...
I've added this as an answer so that, if it worked, I can can the points...
帕特里克.
这篇关于ASMX:在运行时设置用户/密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!