2011-08-30 58 views
0

這裏是我的代碼,在提供服務的時候從客戶端代碼獲取的瀏覽器認證對話框

$.ajax(
        { 
         type: "POST", 
         url: "counter.asmx/IncreaseCounter", 
         data: "{}", 
         contentType: "application/json; charset=utf-8", 
         dataType: "json", 
         success: LogoutSuccess, 
         error: AjaxFailed 
        } 
        ); 

調用Web服務在我的本地機器,這是正常工作,但之後生產部署 出現呼叫瀏覽器彈出式身份驗證框,這不允許我繼續。 我想擺脫這個身份驗證彈出當webservice從我的網站的網頁調用。

表示我不希望對此Web服務進行任何驗證。

一些谷歌後,我加入以下節點在我的web.config文件但它仍然要我輸入憑據

<system.web.extensions> 
    <scripting> 
     <webServices> 
     <authenticationService enabled="false" /> 
     </webServices> 
    </scripting> 
    </system.web.extensions> 

請給我建議的解決方案這是我的Web服務代碼

[WebService(Namespace = "http://tempuri.org/")] 
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService] 
public class counter : System.Web.Services.WebService 
{ 

    public counter() 
    { 

     //Uncomment the following line if using designed components 
     //InitializeComponent(); 
    } 

    [WebMethod(Description = "Per session Hit Counter", EnableSession = true)] 
    public void IncreaseCounter(string PostURL) 
    { 
     string url= HttpUtility.UrlDecode(PostURL); 
     DBAdministrator.IncreasePostVisitCount(url); 
    } 
} 

回答

0

這非常奇怪;頁面和服務都需要身份驗證,否則都不需要身份驗證。

由於您使用相對URL,加載頁面應該已經彈出了auth框。之後,用戶應該有一個會話。

檢查兩件事情:

  1. 沒有用於服務(例如在瀏覽器和服務器等之間的代理)的網址沒有具體的手動配置。
  2. WsiProfiles.BasicProfile1_1讓我想知道......常數是什麼意思? 「基本」聽起來像「基本認證方案」。檢查是否有其他值可以使用。