我正在开发Microsoft Visual Studio 2013社区版,Webforms。 开发环境是Windows8.1,IIS版本是8.5。
1)在调试期间(使用开发服务器),它显示为"连接成功!!"当你按下" LogInMe"按钮。 但是,在我在IIS中指定的文件夹中部署失败并调用"错误!!"。 (该文件夹的权限是Everyone。并且Windows的防火墙功能无效。)
2)只是为了补充信息...... 在IIS文件夹中部署后," http://localhost/TEST/TEST.aspx"显示为预期页面。 但是在" http://localhost/TEST/TESTWCF.SVC" ;,消息显示,"无法找到终点。“
如何修复代码?或者有没有地方可以查看IIS设置?
以下是Web.config的一部分
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="DaishinWCFAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="Shop.DaishinWCF">
<endpoint address="" behaviorConfiguration="DaishinWCFAspNetAjaxBehavior"
binding="webHttpBinding" contract="Shop.DaishinWCF" />
</service>
</services>
</system.serviceModel>
&#13;
以下是TESTWCF.svc.vb的查看代码
Imports System.ServiceModel
Imports System.ServiceModel.Activation
Imports System.ServiceModel.Web
Imports System.Web.Providers.Entities
Imports System.Runtime.Serialization.Json
Imports System.ServiceModel.Description
Imports System.Runtime.Serialization
Imports Newtonsoft.Json
<ServiceContract()>
Public Interface IService1
<OperationContract()> _
<WebInvoke(Method:="GET", ResponseFormat:=WebMessageFormat.Json)> _
Function fnVerifyID(ByVal ID As String, ByVal PASS As String)
End Interface
<DataContract()> _
Public Class csVerifyID
Dim sID As String
Dim iFlg As Integer
Dim sName As String
<DataMember()> _
Public Property Name() As String
Get
Return sName
End Get
Set(value As String)
sName = value
End Set
End Property
End Class
<ServiceContract(Namespace:="")> _
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>
Public Class DaishinWCF
<WebGet()>
Public Function fnVerifyID(ByVal ID As String, ByVal PASS As String)
Dim Hyouji As String = CStr(ID) & CStr(PASS)
Dim objVeryfyID As New csVerifyID
objVeryfyID.Name = "Connection Succeeded!!"
Dim person As String = JsonConvert.SerializeObject(objVeryfyID)
Return person
End Function
End Class
&#13;
下面是Test.aspx
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Mobile.Master" CodeBehind="Test.aspx.vb" Inherits="Shop.Daishin" %>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<head>
<!DOCTYPE html>
<title>Test Title</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css"/>
<link rel="stylesheet" href="css/custom.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<%--<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>--%>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
<script src="js/jCarousel.min.js" type="application/x-javascript" charset="utf-8"></script>
<script src="js/custom.js"></script>
<script type="text/javascript">
$(function () {
$('#LogInMe').click(function () {
var UserName = $('#txtUserName').val()
var Password = $('#txtPassword').val()
var Para = { ID: $('#txtUserName').val(), PASS: $('#txtPassword').val() };
$.ajax({
url: '/TestWCF.svc/fnVerifyID',
type: 'GET',
dataType: 'json',
contentType: "application/json; charset=utf-8",
traditional: true,
data: Para ,
success: function (response) {
var obj = JSON.parse(response.d);
alert(obj.Name)
},
error: function (xhr, status, err) {
alert('Connection Error!!');
}
});
});
});
</script>
</head>
<body>
<div data-role="page" data-add-back-btn="true" id="p-listview-thumbnail" >
<div data-role="header" data-position="fixed" data-theme="d">
<h1></h1>
<a href="#Family" data-icon="gear" class="ui-btn-right" data-iconpos="notext" data-theme="d" >Options</a>
<input type="text" id="txtUserName" placeholder="Username" />
<input type="password" name="passwordinput" id="txtPassword" placeholder="Password" value="" />
<a href="javascript:Authenticate();" id="LogInMe" data-role="button" data-icon="check" data-iconpos="right">Log Me In!</a>
<label for="basic_name" id="lblMessage"></label>
</div>
</body>
</html>
</asp:Content>