-1

我嘗試從MVC應用程序GET到OWIN SelfHost中進行查詢。兩者都有WindowsAuth。 MVC從一個虛擬機中的Visual Studio運行,OWIN SelfHost作爲其他虛擬機中的服務運行。響應始終是401.我嘗試在WebRequest中設置Credentials,PreAuthenticate - 沒有任何更改。我不能讓匿名身份驗證在我的系統中。我該如何提出要求?謝謝。嘗試GET到OWIN SelfHost時出現401錯誤

回答

0

,可知該溶液:

WebRequest req = WebRequest.Create(Properties.Settings.Default.SelfHostAdress + "/api/data/GetReportsOrgStructTreeView?currentUserName=" + currentUsername + "&parentNodeId=" + parentNodeId + "&filterId=" + filterId); 
       req.UseDefaultCredentials = true; 
       req.PreAuthenticate = true; 
       WebResponse resp = req.GetResponse(); 
       System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream()); 
       content = sr.ReadToEnd(); 
       return content; 
相關問題