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);
}
}