HTTP 404错误,而在调用.NET MVC4本地Web服务 [英] HTTP 404 error while invoking a local webservice in .NET MVC4

查看:534
本文介绍了HTTP 404错误,而在调用.NET MVC4本地Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想学习.NET Web服务mvc4。我试图创建一个新的互联网应用,并添加Web服务(ASMX)到项目中。

I am trying to learn webservices in .NET mvc4. I tried creating a new Internet application and adding a Web service (asmx) to the project.

默认情况下,VS增加了一个HelloWorld的web服务。当我尝试在浏览器中运行它,我得到的操作列表,服务描述(WSDL)和 HellowWorld 操作的细节。然而,当我尝试调用web服务,它提供了以下错误:

By default, the VS adds a "HelloWorld" Webservice. When I try to run it in the browser, I do get the list of operations, service description(WSDL) and the details of the HellowWorld operation. However, when I try invoking the webservice, it gives the following error :

中的服务器错误'/'应用。

Server Error in '/' Application.

资源无法找到。

说明:HTTP 404。您正在寻找(或一个资源的
  依赖)可能已被删除,更名,或
  暂时不可用。请检查以下URL并
  确认其拼写正确。

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

我可能会丢失一些基本的步骤/设置我猜。莫非一些身体帮助,请。谢谢你。

I might be missing some basic step/setting I guess. Could some body help please. Thanks.

推荐答案

我得到的回答从我的同事:)之一。

I got the answer from one of my colleagues :) .

当我们调用的服务,MVC试图在指定的RegisterRoutes解决的路径。
因此,它试图找到具有该名称的控制器和具有名称相同该控制器内操作的方法。该决议忽略了与扩展的.asmx的路径。您可以通过添加下面的行RouteConfig.cs做到这一点:

When we invoke the service, the MVC tries to resolve the path as specified in RegisterRoutes. Hence it tries to find a controller with that name and a method with the name same as that of the operation inside that controller. The resolution, ignore the paths with .asmx extension. You can do that by adding the following line in RouteConfig.cs :

routes.IgnoreRoute("{*x}", new { x = @".*\.asmx(/.*)?" }); 

和它的工作。谢谢你。

这篇关于HTTP 404错误,而在调用.NET MVC4本地Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆