用c#开发的webservice怎么样才能在Linux里使用

qq_37250198 2018-04-17 08:14:27
就像我现在服务器是虚拟机,win系统、里面开着iis弄的、
现在我想把这个服务器改为Linux怎么做,也没有什么办法可以让Linux也是用这个webservice
...全文
2063 26 打赏 收藏 转发到动态 举报
写回复
用AI写文章
26 条回复
切换为时间正序
请发表友善的回复…
发表回复
Xing_h_y 2018-10-30
  • 打赏
  • 举报
回复
引用 6 楼 qq_37250198 的回复:
不对不对我的目的是:Linux里放着webservice随后让win里的c#访问这个webservice


直接再vs中引用服务中,引入你在linux中布局的ip及名称就好了啊。
stherix 2018-10-29
  • 打赏
  • 举报
回复
引用 26 楼 qq_42142727 的回复:
[quote=引用 22 楼 From_TaiWan 的回复:] [quote=引用 21 楼 qq_37250198 的回复:] [quote=引用 20 楼 From_TaiWan 的回复:] 安装一个vs2017,里面有.Core,建立一个.Core项目,然后将原来的代码复制,生成Linux下的
可是如果我把webervice.asmx.cs里的东西照抄到Program.cs里就会有一大堆红字呀、头文件里的using System.Web.Services;using System.Web.Services.Protocols;都不可以,这样我下面的很多东西都不行了呀[/quote]根据红字提示,在“引用”里添加dll,并using相关类型[/quote] 生成.core项目后,在linux里使用什么发布webservice呢[/quote] 用nginx啊,只不过.net core库和framework有一点点区别,代码要少量改动,基本上移植很容易的
qq_42142727 2018-10-27
  • 打赏
  • 举报
回复
引用 22 楼 From_TaiWan 的回复:
[quote=引用 21 楼 qq_37250198 的回复:]
[quote=引用 20 楼 From_TaiWan 的回复:]
安装一个vs2017,里面有.Core,建立一个.Core项目,然后将原来的代码复制,生成Linux下的


可是如果我把webervice.asmx.cs里的东西照抄到Program.cs里就会有一大堆红字呀、头文件里的using System.Web.Services;using System.Web.Services.Protocols;都不可以,这样我下面的很多东西都不行了呀[/quote]根据红字提示,在“引用”里添加dll,并using相关类型[/quote]
生成.core项目后,在linux里使用什么发布webservice呢
qq_42142727 2018-10-27
  • 打赏
  • 举报
回复
我不太理解这句话:代码移到.NetCore下编译就可以了
webservice在windows里用IIS,到linux下用什么?
hez2010 2018-05-16
  • 打赏
  • 举报
回复
dotnet new webapi,.net core通过这种方式建立新的Web Api程序,建立好后用vs打开写代码就行了。跟以前可能会稍微有一些变化。
qq_37250198 2018-05-16
  • 打赏
  • 举报
回复
引用 22 楼 From_TaiWan 的回复:
[quote=引用 21 楼 qq_37250198 的回复:] [quote=引用 20 楼 From_TaiWan 的回复:] 安装一个vs2017,里面有.Core,建立一个.Core项目,然后将原来的代码复制,生成Linux下的
可是如果我把webervice.asmx.cs里的东西照抄到Program.cs里就会有一大堆红字呀、头文件里的using System.Web.Services;using System.Web.Services.Protocols;都不可以,这样我下面的很多东西都不行了呀[/quote]根据红字提示,在“引用”里添加dll,并using相关类型[/quote] using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.IO; using System.Security.Cryptography; namespace WebApplication1 { /// <summary> /// WebService1 的摘要说明 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。 // [System.Web.Script.Services.ScriptService] public class WebService1 : System.Web.Services.WebService { [WebMethod(Description = "上传去的路径")] private string FilePath(string fileName) { string serverPath = Path.Combine(Server.MapPath("") + @"\Upload\"); if (!Directory.Exists(serverPath))//存在么 Directory.CreateDirectory(serverPath);//新建一个 return Path.Combine(Server.MapPath("") + @"\Upload\" + Path.GetFileName(fileName)); } [WebMethod] public string HelloWorld() { return "Hello World"; } [WebMethod(Description = "创建文件")] public bool CreateFile(string fileName) { bool isCreate = true; try { FileStream fs = new FileStream(FilePath(fileName), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); fs.Close(); } catch { isCreate = false; } return isCreate; } [WebMethod(Description = "附加文件流")] public bool Append(string fileName, byte[] buffer) { bool isAppend = true; try { FileStream fs = new FileStream(FilePath(fileName), FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); fs.Seek(0, SeekOrigin.End); fs.Write(buffer, 0, buffer.Length); fs.Close(); } catch { isAppend = false; } return isAppend; } [WebMethod(Description = "验证文件是否一致")] public bool Verify(string fileName, string md5) { bool isVerify = true; try { string md5Str = ""; FileStream fs = new FileStream(FilePath(fileName), FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); MD5CryptoServiceProvider md5Temp = new MD5CryptoServiceProvider(); byte[] md5Buffer = md5Temp.ComputeHash(fs); fs.Close(); List<string> strList = new List<string>(); for (int i = 0; i < md5Buffer.Length; i++) { md5Str += md5Buffer[i].ToString("x2"); } if (md5 != md5Str) { isVerify = false; } } catch { isVerify = false; } return isVerify; } [WebMethod(Description = "下载来的路径")] private string FilePath2(string fileName) { string serverPath = Path.Combine( @"D:\Download\"); if (!Directory.Exists(serverPath)) Directory.CreateDirectory(serverPath); return Path.Combine(@"D:\Download\" + Path.GetFileName(fileName)); } [WebMethod(Description = "创建文件")] public bool CreateFile2(string fileName) { bool isCreate = true; try { FileStream fs = new FileStream(FilePath2(fileName), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); fs.Close(); } catch { isCreate = false; } return isCreate; } [WebMethod(Description = "附加文件流")] public bool Append2(string fileName, byte[] buffer) { bool isAppend = true; try { FileStream fs = new FileStream(FilePath2(fileName), FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); fs.Seek(0, SeekOrigin.End); fs.Write(buffer, 0, buffer.Length); fs.Close(); } catch { isAppend = false; } return isAppend; } [WebMethod(Description = "验证文件是否一致")] public bool Verify2(string fileName, string md5) { bool isVerify = true; try { string md5Str = ""; FileStream fs = new FileStream(FilePath2(fileName), FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); MD5CryptoServiceProvider md5Temp = new MD5CryptoServiceProvider(); byte[] md5Buffer = md5Temp.ComputeHash(fs); fs.Close(); List<string> strList = new List<string>(); for (int i = 0; i < md5Buffer.Length; i++) { md5Str += md5Buffer[i].ToString("x2"); } if (md5 != md5Str) { isVerify = false; } } catch { isVerify = false; } return isVerify; } } } 我的webservice,很多我也找不到可以引用的地方
秋的红果实 2018-05-10
  • 打赏
  • 举报
回复
引用 21 楼 qq_37250198 的回复:
[quote=引用 20 楼 From_TaiWan 的回复:] 安装一个vs2017,里面有.Core,建立一个.Core项目,然后将原来的代码复制,生成Linux下的
可是如果我把webervice.asmx.cs里的东西照抄到Program.cs里就会有一大堆红字呀、头文件里的using System.Web.Services;using System.Web.Services.Protocols;都不可以,这样我下面的很多东西都不行了呀[/quote]根据红字提示,在“引用”里添加dll,并using相关类型
qq_37250198 2018-05-08
  • 打赏
  • 举报
回复
引用 16 楼 xomix 的回复:
[quote=引用 15 楼 qq_37250198 的回复:] [quote=引用 13 楼 xomix 的回复:] .net core mono 这两个是直接布置的可商用解决方案,布置和使用难度不会比其他方法做的大,如果能移植.net core当然最好最快,不能可以用mono。
那就是说我直接用.net core重写webservice么;现在我在.net core里写可是提示system.web.services没有[/quote] mono你不用重写,你就直接在服务器安装mono,然后把你的项目拿到mono的编辑器里面,发布一下,复制到linux服务器,然后就行了。[/quote] 我VM里的ubuntu里已经安装好了nginx,也安装好了monodevelop,想发布一个webservice给自己,但是怎么才能发布,如果我直接monodevelop选择release,虚拟机上会出现127.0.0.1:8080的一个Default的网页,但是我主机找不到这个面,而且只能选nginx的80端口,出现的是welcome nginx,(此外,我nginx如果配置成8080口,那么monodevelop就没办法release或者debug了),那我究竟应该怎么做才能出这个webservice;我找不到浅显易懂的教程,哪儿有教发布的贴。
极客诗人 2018-05-08
  • 打赏
  • 举报
回复
移到core 上去啊
qq_37250198 2018-05-08
  • 打赏
  • 举报
回复
引用 20 楼 From_TaiWan 的回复:
安装一个vs2017,里面有.Core,建立一个.Core项目,然后将原来的代码复制,生成Linux下的
可是如果我把webervice.asmx.cs里的东西照抄到Program.cs里就会有一大堆红字呀、头文件里的using System.Web.Services;using System.Web.Services.Protocols;都不可以,这样我下面的很多东西都不行了呀
秋的红果实 2018-05-08
  • 打赏
  • 举报
回复
安装一个vs2017,里面有.Core,建立一个.Core项目,然后将原来的代码复制,生成Linux下的
qq_37250198 2018-05-08
  • 打赏
  • 举报
回复
引用 18 楼 weixin_38925245 的回复:
移到core 上去啊
可是.core里我找不到什么项目里可以新建一个webservice哎、哪里有webservice.asmx这个文件呢
  • 打赏
  • 举报
回复
引用 15 楼 qq_37250198 的回复:
[quote=引用 13 楼 xomix 的回复:] .net core mono 这两个是直接布置的可商用解决方案,布置和使用难度不会比其他方法做的大,如果能移植.net core当然最好最快,不能可以用mono。
那就是说我直接用.net core重写webservice么;现在我在.net core里写可是提示system.web.services没有[/quote] mono你不用重写,你就直接在服务器安装mono,然后把你的项目拿到mono的编辑器里面,发布一下,复制到linux服务器,然后就行了。
qq_37250198 2018-05-05
  • 打赏
  • 举报
回复
引用 13 楼 xomix 的回复:
.net core mono 这两个是直接布置的可商用解决方案,布置和使用难度不会比其他方法做的大,如果能移植.net core当然最好最快,不能可以用mono。
那就是说我直接用.net core重写webservice么;现在我在.net core里写可是提示system.web.services没有
  • 打赏
  • 举报
回复
.net core mono 这两个是直接布置的可商用解决方案,布置和使用难度不会比其他方法做的大,如果能移植.net core当然最好最快,不能可以用mono。
大然然 2018-04-28
  • 打赏
  • 举报
回复
.net core 没有之一
好的哦 2018-04-27
  • 打赏
  • 举报
回复
1#正解,正好在玩.net core
qq_37250198 2018-04-27
  • 打赏
  • 举报
回复
引用 9 楼 caozhy 的回复:
wine支持,虚拟机,或者用webkit改写
那我是不是可以直接用wine安装好.netframework和iis并且直接用iis开啊?
threenewbee 2018-04-25
  • 打赏
  • 举报
回复
wine支持,虚拟机,或者用webkit改写
qq_37250198 2018-04-25
  • 打赏
  • 举报
回复
引用 7 楼 guwei4037 的回复:
linux中还是使用成熟的java方案,提供webservice。ws是通用的,客户端调用就随意用什么语言了。
那我现在写的这个ws怎么办就重写么 有没有什么可以让Linux部署我目前这个ws的办法啊
加载更多回复(6)

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧