zoukankan      html  css  js  c++  java
  • 类库服务寄宿到WebHost

    1.该Demo中包含一个类库项目、一个空的WebForm项目

    2.新建WebForm项目

    3.全局路由中注册类库服务

    public class Global : System.Web.HttpApplication
        {
            protected void Application_Start(object sender, EventArgs e)
            {
                RegisterRoutes();
    
    
                System.ServiceModel.WebHttpBinding bing = new System.ServiceModel.WebHttpBinding();
                bing.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas() { MaxStringContentLength = 2147483647 }; //(更改这个数字) 
                bing.MaxReceivedMessageSize = 2147483647;
            }
            private void RegisterRoutes()
            {
                RouteTable.Routes.Add(new ServiceRoute("blog", new WebServiceHostFactory(), typeof(ClientApiTest.Class1)));
    
            }
        }
    

      

    4.新建类库服务项目ClientApiTest

    [ServiceContract]
        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
        public class Class1
        {
            [WebInvoke(Method = "POST", UriTemplate = "blog/publish/micoblog", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
            public PublishMicoBlogResponse PublishMicoBlog(PublishMicoBlogRequest request)
            {
                PublishMicoBlogResponse re = new PublishMicoBlogResponse();
                return re;
            }
        }
    

      

    5.启动测试(报错,修改配置)

    http://localhost:54235/blog/blog/publish/micoblog

     6.WebHost修改配置:

     <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
      </system.serviceModel>
    

      

  • 相关阅读:
    C++虚函数表解析(转)
    学习网址
    css 段落文字换行问题
    移动端fixed兼容问题
    半数集1
    汇编寄存器
    设计模式概述
    Vector用法介绍
    汇编PC硬件基本特征
    android 反编译总结
  • 原文地址:https://www.cnblogs.com/liuqiyun/p/9224070.html
Copyright © 2011-2022 走看看