【发布时间】:2011-05-03 19:04:03
【问题描述】:
我正在开发一个网络应用程序,我想通过它的 url 调用一个网络服务。我怎样才能做到这一点?
我在 global.asax 中注册了以下路线;
routes.MapRoute(
"ServiceHandler",
"{*path}/{*.svc}",
new { Url = "Services/Service.svc/GetLatestTweets" }
);
我想调用 web 服务,在这种情况下,通过类似于下面的 url 从 twitter 获取最新消息;
http://www.domainname.com/Services/Service.svc/GetLatestTweets
当我使用上面提到的注册路由时,我在下面添加的 stackstrace 中遇到了错误。
[ArgumentException: A catch-all parameter can only appear as the last segment of the route URL.
Parameter name: routeUrl]
System.Web.Routing.RouteParser.Parse(String routeUrl) +3823656
System.Web.Routing.Route..ctor(String url, IRouteHandler routeHandler) +24
System.Web.Mvc.RouteCollectionExtensions.MapRoute(RouteCollection routes, String name, String url, Object defaults, Object constraints, String[] namespaces) +86
System.Web.Mvc.RouteCollectionExtensions.MapRoute(RouteCollection routes, String name, String url, Object defaults, Object constraints) +28
System.Web.Mvc.RouteCollectionExtensions.MapRoute(RouteCollection routes, String name, String url, Object defaults) +18
CMS.Presentation.FrontEnd.Framework.CMSApplication.RegisterRoutes(RouteCollection routes) in C:\Projects\Website\Web.Presentation\FrontEnd\Framework\CMSApplication.cs:62
CMS.Presentation.FrontEnd.Framework.CMSApplication.Application_Start() in C:\Projects\Website\Web.Presentation\FrontEnd\Framework\CMSApplication.cs:80
[HttpException (0x80004005): A catch-all parameter can only appear as the last segment of the route URL.
Parameter name: routeUrl]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +3988565
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +325
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375
[HttpException (0x80004005): A catch-all parameter can only appear as the last segment of the route URL.
Parameter name: routeUrl]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11529072
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4784373
我应该做什么或改变,以便我可以通过它的 url 调用 web 服务?我正在使用一个简单的 wcf 服务
【问题讨论】:
标签: c# asp.net-mvc wcf web-services routing