今天想起接触WCF(Windows Communiction Foundation),开始弄个很小的例子。
1.建立WCF project
默认的方法改为
public string GetData(int value)
{
System.Threading.Thread.Sleep(5000); //模拟等待
return string.Format ("You entered: {0}", value);
}
就加一句
System.Threading.Thread.Sleep(5000); //模拟等待
2.加入MCF/MCF.aspx VIEW
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
WCF
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script src="http://www.cnblogs.com/Scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(function() {
});
</script>
<h2>
WCF</h2>
<%using (Html.BeginForm())
{ %>
<div id="divResult">
<h3>
Result</h3>
<fieldset>
<div id="divLoading">
<img src='<%=Url.Content ("~/Content/images/loader.gif")%>' alt="load" />
please waiting...</div>
<div id="DivResultData">
</div>
</fieldset>
</div>
<%} %>
</asp:Content>