如何知道web服务无法在asp.net中连接? [英] How to know web service cannot connect in asp.net ?

查看:96
本文介绍了如何知道web服务无法在asp.net中连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有两个网站,比如web1和web2,在web2中我有web服务功能并返回web1的值。我的意思是我使用web2作为数据库连接,使用web2 web services检索和存储值。形式web1我会打电话给网络服务。下面是一个Web服务调用表单web1



Hi I have two websites like web1 and web2,in web2 i have web services function and return value to web1.I mean i use web2 as database connection for retrieve and store value using web2 web services.Form web1 i will call web service. Below one is web service call form web1

function EPlogin(epusername, eppwd) {
				    try {
                       
						$.ajax({
						    type: "POST",
						     url: "http://192.168.168.91/web2/EPService.asmx/EP_Login",
							data: "{username: '" + encodeURIComponent(epusername) + "', pwd: '" + encodeURIComponent(eppwd) + "'}",
							contentType: "application/json; charset=utf-8",
							dataType: "json",                               
							jsonpCallback: "success",
							success: function (result) {
								                            
								var loginfo = eval(result.d);
					if (loginfo.lengthgt; 1) {
						                         
                                    window.location = "home_kendo.html";
                                   }
								else {
								    alert(loginfo[0]);
									$("#ErrorDiv").text(loginfo[0]);									
								}
							},
							fail: function (msg) {
							      alert(msg.statusText);
							if (msg.status == 0) {
									$("#ErrorDiv").text("No internet connection or Server down");                                        
								}
								else {                                        
									$("#ErrorDiv").text(msg.statusText + " " + msg.status);
								}
                                                                   
								
							}
						})
					}
				    catch (ex) {
				        alert(ex.message)
						$("#ErrorDiv").text(ex.message);
					}
}





在上面我提到了收件人和根文件夹名称(web2),如果是ip地址无法连接或根文件夹错误,那时我需要显示错误信息。如何显示错误信息。



注意:在上面的捕获或者失败的功能我dint得到任何错误,如果我使用F12并检查浏览器然后只有我收到错误消息。如无法访问的地址或net :: ERR_CONNECTION_TIMED_OUT。请查看以下链接。



http://prntscr.com/51hblc [ ^ ]



我需要检查编码本身,而不是粘贴url链接浏览器和检查,我需要错误消息提醒。



问候

Aravind



In above i mention addressees and root folder name(web2),in that if ip address can't connect or if root folder is wrong,that time i need to show error message.So how to show error message.

Note:In above catch or fail function i dint get any error,if i use F12 and check in browser then only i get error message.like unreachable address or net::ERR_CONNECTION_TIMED_OUT. Pls check below link.

http://prntscr.com/51hblc[^]

I need to check in coding itself,not like paste url link browser and check,i need error message alert.

Regards
Aravind

推荐答案

.ajax({
type:POST,
url:http://192.168.168.91/web2/EPService.asmx / EP_Login,
data:{username:'+ encodeURIComponent(epusername)+',pwd:'+ encodeURIComponent(eppwd)+'},
contentType:application / json ; charset = utf-8,
dataType:json,
jsonpCallback:成功,
成功:函数(结果){

var loginfo = eval(result.d);
if(loginfo.lengthgt; 1){

window.location =home_kendo.html;
}
else {
alert(loginfo [0]);
.ajax({ type: "POST", url: "http://192.168.168.91/web2/EPService.asmx/EP_Login", data: "{username: '" + encodeURIComponent(epusername) + "', pwd: '" + encodeURIComponent(eppwd) + "'}", contentType: "application/json; charset=utf-8", dataType: "json", jsonpCallback: "success", success: function (result) { var loginfo = eval(result.d); if (loginfo.lengthgt; 1) { window.location = "home_kendo.html"; } else { alert(loginfo[0]);


(#ErrorDiv)。text(loginfo [0]);
}
},
失败:function(msg){
alert(msg.statusText);
if(msg.status == 0){
("#ErrorDiv").text(loginfo[0]); } }, fail: function (msg) { alert(msg.statusText); if (msg.status == 0) {


(#ErrorDiv)。text(无互联网连接或服务器关闭);
}
else {
("#ErrorDiv").text("No internet connection or Server down"); } else {


这篇关于如何知道web服务无法在asp.net中连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆