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 }
);
}
}
}

浙公网安备 33010602011771号