zoukankan      html  css  js  c++  java
  • WebService 写在项目中无法运行问题

    有时项目需要,需要将webservice 写在项目中,这样就会导致服务无法运行,进行测试

    有两种方法可以解决

      1.将项目部署到IIS上,这样就可以测试webservice

      2.自己手动配置一下路由,代码如下    routes.IgnoreRoute("{*allasmx}", new { allasmx = @".*.asmx(/.*)?" });   将代码放到路由配置的地方,就可以访问测试了。

      

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Web.Routing;
    
    namespace Nova.WMS.WebSite
    {
        public class RouteConfig
        {
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
                routes.IgnoreRoute("{*allasmx}", new { allasmx = @".*.asmx(/.*)?" }); //测试webservice 时配置路由
    
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "NewIndex", id = UrlParameter.Optional }
                );
            }
        }
    }
    

      

  • 相关阅读:
    @atcoder
    @loj
    @AGC037
    @uoj
    @uoj
    @loj
    @loj
    @loj
    @loj
    @loj
  • 原文地址:https://www.cnblogs.com/qiao298/p/13800826.html
Copyright © 2011-2022 走看看