【发布时间】:2014-10-06 11:23:33
【问题描述】:
我是 MVC 的新手。我只想使用 mvc 和 wcf 服务在我的页面上显示故事标题列表。调试我的应用程序后抛出异常:
找不到引用合约的默认端点元素 ServiceModel 客户端配置中的“ServiceReference1.IService1” 部分。这可能是因为找不到配置文件 您的应用程序,或者因为没有与此匹配的端点元素 合同可以在客户端元素中找到。
代码如下:
HomeController.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcMovie.Controllers
{
public class HomeController : Controller
{
// ServiceReference1.Service1Client cs = new ServiceReference1.Service1Client();
public ActionResult Index()
{
//ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
ServiceReference1.Service1Client cs = new ServiceReference1.Service1Client();
List<ServiceReference1.Story> tm = cs.GetBollywoodStory();
return View();
}
}
}
Index.cshtml
@{
ViewBag.Title = "Index";
}
<h2>My Movie List</h2>
<p>Hello from our View Template!</p>
@*<%n ServiceReference1.Service1Client cs = new ServiceReference1.Service1Client();%>
*@Name
<%foreach (ServiceReference1.Story dr in tm)
{%>
<%=dr["Name"].ToString() %>
<% } %>
请帮帮我.....
【问题讨论】:
标签: c# asp.net-mvc wcf asp.net-mvc-4 razor