简体   繁体   English

使用visual studio 2013在C#中创建asmx Web服务

[英]Create a asmx web service in C# using visual studio 2013

Hy, HY,

how can I create a asmx web service in Visual Studio 2013? 如何在Visual Studio 2013中创建asmx Web服务?

I have found this short tutorial about that, but when I follow this in Visual Studio 2013 I get an error that says "the type 'Service1' could not be created". 我已经找到了这个简短的教程,但是当我在Visual Studio 2013中使用它时,我收到一条错误,上面写着“无法创建类型'Service1'”。

Thanks for help :) 感谢帮助 :)

  1. Create Empty ASP.NET Project 创建空ASP.NET项目 在此输入图像描述
  2. Add Web Service(asmx) to your project 将Web服务(asmx)添加到项目中
    在此输入图像描述

Short answer: Don't do it. 简短的回答:不要这样做。

Longer answer: Use WCF. 更长的答案:使用WCF。 It's here to replace Asmx. 它就是取代Asmx。

see this answer for example, or the first comment on this one . 看到这个答案 ,例如,或在第一次评论这一个

John Saunders : ASMX is a legacy technology, and should not be used for new development. John Saunders :ASMX是一项传统技术,不应用于新开发。 WCF or ASP.NET Web API should be used for all new development of web service clients and servers. WCF或ASP.NET Web API应该用于Web服务客户端和服务器的所有新开发。 One hint: Microsoft has retired the ASMX Forum on MSDN. 一个提示:微软已经退出了MSDN上的ASMX论坛。


As for comment ... well, if you have to, you have to. 至于评论......好吧,如果必须,你必须这样做。 I'll leave you in the competent hands of the other answers then. 那么我会把你留在其他答案的主管手中。 (Even though it's funny it has issues, and if it does, why are you doing it in VS2013 to begin with ?) (虽然它很有趣它有问题,如果确实如此,你为什么要在VS2013开始这样做呢?)

在网站框中,您选择了.NETFramework 4.5并且它没有显示,所以点击那里并选择3.5 ...我希望它有所帮助。

Check your namespaces. 检查您的命名空间。 I had and issue with that. 我曾经和那个问题一样。 I found that out by adding another web service to the project to dup it like you did yours and noticed the namespace was different. 我发现通过向项目添加另一个Web服务来复制它就像你做的那样,并注意到名称空间不同。 I had renamed it at the beginning of the project and it looks like its persisted. 我在项目开始时将其重命名,看起来它仍然存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM