English 中文(简体)
401 - 未经许可: 由于全权证书无效,不准查阅。
原标题:401 - Unauthorized: Access is denied due to invalid credentials

我试图消耗第三方的服务:

 var context = new DataSource(new Uri("http://api.olr.com/Service.svc"));

 context.Credentials = new NetworkCredential("username", "password", "http://api.olr.com/Service.svc");


 var agents = from a in context.Agents
                     select a;

 tbResponse.Text = agents.FirstOrDefault().ToString();

而后退:

<div class="content-container"><fieldset>
 <h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
 <h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
</fieldset></div>
</div>

我试图利用浏览器获得服务,并正在工作。

下面线的第三个参数是领域。 哪些领域? 该处的午餐与否?

context.Credentials = new NetworkCredential("username", "password", "http://api.olr.com/Service.svc");
最佳回答

网络建筑商正在期待用户名、密码和域名,但你正在全乌尔都而不是通过。

我将把这一行文改为:

context.Credentials = new NetworkCredential("username", "password", "olr.com");

<>UPDATE - Solutions that work:

context.Credentials = new NetworkCredential("username", "password");

解决办法。

问题回答

您应通过与通过全权证书相关的领域。 你所提到的服务是用一些机器提供的,我猜测你应当通过机器的域名。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签