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>
    

      

  • 相关阅读:
    力学,结构动力NewMark法软组织模拟
    力学,非线性形变
    力学,线性形变
    波动方程水面模拟(简版)
    FFT海面(简版)
    测地极坐标参数化纹理贴图
    参数化离散指数映射纹理贴图
    Gridview中各个事件的操作以及FindControl
    CSS样式
    博客声明(博客大多均非原创文章,只用于记录)
  • 原文地址:https://www.cnblogs.com/liuqiyun/p/9224070.html
Copyright © 2011-2022 走看看