我已经创建了一个DynamicsNAV2016CodeUnitWebService( Stream),我想在ASP.NET 4 Web应用程序中使用它。
为了进行身份验证,我需要使用Windows凭据。这是一个非常简短的代码示例。
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); )时,一切都按其应有的方式工作,但凭据是通过编程提供的.
有人有办法解决这个问题吗?
提前感谢
发布于 2017-04-20 19:53:41
您检查了的设置吗?在“安全”选项卡下,您可以调整安全区域。有一个用户身份验证选项,您应该签出该选项。
https://stackoverflow.com/questions/43111213
复制相似问题