首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >[NAV/ASP.NET]Web服务凭据

[NAV/ASP.NET]Web服务凭据
EN

Stack Overflow用户
提问于 2017-03-30 07:27:10
回答 1查看 734关注 0票数 0

我已经创建了一个DynamicsNAV2016CodeUnitWebService( Stream),我想在ASP.NET 4 Web应用程序中使用它。

为了进行身份验证,我需要使用Windows凭据。这是一个非常简短的代码示例。

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CleanWebApp
{
    using GridRef; //Web Reference
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Grid grid = new Grid(); //New instance of the Web Service
                grid.UseDefaultCredentials = true; //Use the DefaultCredentials (system credentials of the application)

                //Create a table rows and cells based on the return values of the Codeunit functions
                int columns = grid.SendColumnsToWeb();
                int rows = grid.SendRowsToWeb();

                for (int i = 0; i < rows; i++)
                {
                    TableRow tr = new TableRow();
                    for (int j = 0; j < columns; j++)
                    {
                        TableCell tc = new TableCell();
                        tc.Controls.Add(new LiteralControl(grid.SendDescToWeb(j + 1, i + 1)));
                        tr.Cells.Add(tc);
                    }
                    DynamicTable.Rows.Add(tr);
                }
            }
[...]

当我从Visual运行此代码时,web应用程序将通过IIS启动,一切正常。现在,我将此项目发布到我的硬盘驱动器,并使用IIS Windows功能运行它。在浏览我的网站时,我会发现一个http status 401 unauthorized错误。

在我的IIS-Manager中启用了Windows身份验证。

在web.config文件中的system.web块中,我添加了<authentication mode="Windows">

当我提供硬编码凭据(用户、密码、域)并使用此代码进行身份验证( grid.Credentials = new System.Net.NetworkCredential(user, password, domain); )时,一切都按其应有的方式工作,但凭据是通过编程提供的.

有人有办法解决这个问题吗?

提前感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-20 19:53:41

您检查了的设置吗?在“安全”选项卡下,您可以调整安全区域。有一个用户身份验证选项,您应该签出该选项。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43111213

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档