【问题标题】:How to consume WCF Data Service from Controller (MVC5, EF6, WCF 5.6)如何从控制器使用 WCF 数据服务(MVC5、EF6、WCF 5.6)
【发布时间】:2013-12-20 11:17:24
【问题描述】:

我按照 microsoft 网站 (Microsoft) 的“入门”中的步骤进行操作

一切都很顺利,直到我在控制器中尝试了这一步:

private Uri svcUri = new Uri("~/Services/ChannelWCF.svc");

context = new ChannelEntities(svcUri);

ChannelEntities 无法识别参数 svcUri,自动生成的 dbcontext 没有带有单个参数的方法...

这是我的 WCF 数据服务:

    public class ChannelWCF : EntityFrameworkDataService<ChannelEntities>
    {

       // This method is called only once to initialize service-wide policies.
       public static void InitializeService(DataServiceConfiguration config)
       {
          config.SetEntitySetAccessRule("QuotaSet", EntitySetRights.All);
          config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
          config.UseVerboseErrors = true;           
      }
}

我可以在 Web 浏览器 (localhost:12345/ChannelWCF.svc) 中看到它,我也可以在视图中直接使用 json 来使用该服务。

谁能给我看灯?谢谢!!

【问题讨论】:

    标签: .net wcf entity-framework


    【解决方案1】:

    您可以在服务参考中直接添加网络服务。只需右键单击 References 选择 Add Service Reference

    查看此链接了解更多详情:

    http://www.c-sharpcorner.com/UploadFile/krishnasarala/accessing-wcf-service-in-Asp-Net-mvc-application/

    【讨论】:

      猜你喜欢
      • 2012-01-14
      • 2013-12-13
      • 2011-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多