标准 Web 服务 (asmx) 是否可以与 MVC 一起使用?

发布于 2024-08-23 05:43:56 字数 343 浏览 6 评论 0原文

我刚刚尝试将 WebService(基于 asmx)从 WebForms 项目添加到新的 MVC 项目。我似乎无法在 IE 中访问 asmx web 服务?

在 MVC 中,这是否应该工作相同,我在服务文件夹中拥有该服务,这应该在视图中还是应该在“MVC”路由之外工作?

更新:

我设置了 WebService,最初将 .asmx 文件放入测试服务器上,最近为 VS2010 MVC 2 项目使用 .Net 4.0 设置。 (Windows Server 2003 IIS 6)

相同的Web服务在开发(VS 2010)机器上是否可见?关于差异的任何想法,可能是设置问题?

I have just tried adding a WebService (asmx based) from a WebForms project to a new MVC project. I cant seem to get to the asmx webservice in IE?

In MVC should this work the same, I have the service in a Services folder, should this be in a View or should this asmx work outside the 'MVC' routing?

Update:

I set up the WebService initially dropping in the .asmx file onto a test server, recently setup with .Net 4.0 for the VS2010 MVC 2 project. (Windows Server 2003 IIS 6)

The same Webservice is on a development (VS 2010) machine is viewable? Any ideas on the difference, possibly a setup issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

oО清风挽发oО 2024-08-30 05:43:56

根据 Scott Hanselman 的说法,默认情况下,该请求由 ASP.NET MVC 路由机制处理:

为什么 ASP.NET MVC 不抓取请求?有两个原因。首先,RouteCollection 上有一个名为 RouteExistingFiles 的选项。默认情况下它设置为 false,这会导致 ASP.NET MVC 在磁盘上存在文件时自动跳过路由。 (来源

这表明其他地方存在问题。

According to Scott Hanselman, the request is by default not handled by the ASP.NET MVC routing mechanism:

Why doesn't ASP.NET MVC grab the request? Two reasons. First, there's an option on RouteCollection called RouteExistingFiles. It's set to false by default which causes ASP.NET MVC to automatically skip routing when a file exists on disk. (Source)

Which would indicate that there is a problem somewhere else.

怪我闹别瞎闹 2024-08-30 05:43:56

如果您想要快速/简单/肮脏的解决方案,请以某种方式将 ASMX 服务从 MVC 路由中拉出。

如果您想以更好的方式做事,请将逻辑从 ASMX 服务中提取出来,并在 MVC 应用程序中为其创建一个新页面。然后,您可以在控制器中实现逻辑,并允许视图处理返回 SOAP 消息(或者您可以使用 JSON,具体取决于谁正在使用该服务)。

If you want the quick/easy/dirty solution, pull the ASMX Service out of the MVC Routing somehow.

If you want to do things the better way, pull the logic out of the ASMX service and create a new page for it in your MVC application. You can then implement the logic in your Controller and allow the View to handle returning the SOAP message (or you could go with JSON depending on who is consuming the service).

月下凄凉 2024-08-30 05:43:56

回答我自己的问题..

创建基本服务时我可以看到 WCF 服务(并且看不到 asmx 服务),

因为 WCF 被认为是可行的方法,所以我正在这样做。

我没有坚持让 asmx 工作。

Answering my own Question..

I can see WCF services when creating a basic service (and cannot see asmx services)

Since WCF is considered the way to go anyway, I am doing that.

I didnt persue getting the asmx to work.

情绪操控生活 2024-08-30 05:43:56

是的,我创建了基础项目,然后右键单击项目名称并添加了一个 webservice 文件,其中包含 hello world 的演示。如果您在浏览器中查看该文件,它就可以正常工作。

YES it does, I created the base project then I right clicked on the project name and added a webservice file with the demo of hello world in it. If you view that file in the browser it works fine.

微暖i 2024-08-30 05:43:56

它应该在 MVC 路由之外工作。只需创建一个包含 asmx 文件的文件夹就足够了。我的项目中有一个“webservices”文件夹,它运行得很好!无需设置路由来忽略路径,该文件确实存在于服务器上。

It should work outside the MVC-routing. Just creating a folder with the asmx-files should be sufficiant. I've got a 'webservices' folder inside my project, and it works great! No need to set the routing to ignore the path, the file does exists on the server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文