2012-11-21 25 views
3

當我嘗試去到一個網頁,我得到這個消息:被提示登錄時,我不應該

HTTP錯誤401.2 - 未經授權您無權查看此 頁面由於無效的認證報頭。

正如你可以從圖中看到:

enter image description here

這是混淆考慮到我從我的登錄屏幕直接到這個頁面,我沒有得到一個提示。我也可以去網站的任何其他部分,而不會被提示。

這裏是我使用的鏈接到這個屏幕的代碼:

@using SuburbanCustPortal.SuburbanService 

<br /> 
<br /> 
<table> 

    @if (ViewData["CustomerData"] != null) { 
    foreach (var usr in (IEnumerable<CustomerData>) ViewData["CustomerData"]) 
    { 
     <tr> 

     <td> 
      <a href="/Customer/ShowCustomer/@usr.AccountId/">View</a> 
     </td> 

     <td> 
      @[email protected] 
     </td> 

     <td> 
      @usr.Name 
     </td> 

     <td> 
      @usr.DeliveryStreet 
     </td> 

     </tr> 
    } 
    } 

</table> 
<br /> 

它有什麼用它做是一個鏈接?如果是這樣,我該如何解決這個問題?

更新#1

這是被稱爲動作:

public ViewResult ShowCustomer(string id) 
{ 
    var corpid = MiscClasses.TokenIdCookie.GetTokenIdCookie(); 
    var sb = new StringBuilder(); 
    sb.AppendLine("SuburbanCustPortal,Controllers.CustomerController.ExistingAccounts"); 
    sb.AppendLine(string.Format("corpid: {0}", corpid)); 
    sb.AppendLine(string.Format("accountid (id): {0}", id)); 
    Logging.LogInfo(sb.ToString(), _asName); 

    var cr = new CustomerRequest(); 
    cr.CompanyId = corpid; 
    cr.Account = id; 

    return View("AccountScreen", _client.GetCustomerByGuid(cr)); 
} 

更新#2

我使用以下驗證:

enter image description here

+0

需要您正在鏈接的操作以及操作返回頁面的標記... – Jared

+1

您在IIS中配置了哪些身份驗證選項? – jgauffin

+3

在IIS上啓用匿名身份驗證... –

回答

3

由於看起來您的IIS要求您通過基本身份驗證質詢/響應進行身份驗證。匿名訪問被禁用,因此會出現認證對話框。

啓用匿名驗證你應該很好去。

爲應啓用日常Asp.net應用程序(包括MVC的)常用的身份驗證方法是:

  • 匿名和
  • 形式

其他所有取決於應用程序的具體要求和/或環境(即域配置)。

+0

k thx我將進行更改並查看結果! – ErocM