提交表单到web service 问题

迷失道 2014-03-31 11:45:14
在web serivce 有个方法

[WebMethod]
public string sendform()
{

string name= HttpContext.Current.Request["name"];

return name

}

类似这样的sendform() 我在另一个网站做了表单并提交后调用这个sendform() ,服务端如何可以直接通过HttpContext.Current.Request获取客户端的所有表单
或者有其它方法介绍也行,反正不想一个个传值,因为表单是动态的。
...全文
138 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ar 2014-04-01
  • 打赏
  • 举报
回复
引用 6 楼 yyl8781697 的回复:

public string sendform()
     {
         NameValueCollection nvcGet = HttpContext.Current.Request.QueryString;//这里可以取所有get过来的值
 NameValueCollection nvcPost = HttpContext.Current.Request.Form;//这里可以取所有post过来的值
string name=//从nvc的键值对里面去name的值;
       
     return name
  
     }
试试
yyl8781697 2014-04-01
  • 打赏
  • 举报
回复

public string sendform()
     {
         NameValueCollection nvcGet = HttpContext.Current.Request.QueryString;//这里可以取所有get过来的值
 NameValueCollection nvcPost = HttpContext.Current.Request.Form;//这里可以取所有post过来的值
string name=//从nvc的键值对里面去name的值;
       
     return name
  
     }
试试
  • 打赏
  • 举报
回复
        [WebMethod]
        public string sendform(string Json)
        {
            //ToDo
            return name;
        }
把表单的数据转成一个Json对象,直接传过去
迷失道 2014-03-31
  • 打赏
  • 举报
回复
怎么没人
迷失道 2014-03-31
  • 打赏
  • 举报
回复
在线 顶下
迷失道 2014-03-31
  • 打赏
  • 举报
回复
引用 4 楼 yyl8781697 的回复:

NameValueCollection nvcGet = HttpContext.Current.Request.QueryString;//这里可以取所有get过来的值
 NameValueCollection nvcPost = HttpContext.Current.Request.Form;//这里可以取所有post过来的值
把所有的值放在键值对立面就好了
可否具体点,我如果通过参数那样传NameValueCollection 就出错提交 不可序列化什么的。像这个 public string sendform(NameValueCollection nvcGet)

[WebMethod]
 public string sendform(NameValueCollection nvcGet)
     {
        
string name= HttpContext.Current.Request["name"];
      
     return name
 
     }
yyl8781697 2014-03-31
  • 打赏
  • 举报
回复

NameValueCollection nvcGet = HttpContext.Current.Request.QueryString;//这里可以取所有get过来的值
 NameValueCollection nvcPost = HttpContext.Current.Request.Form;//这里可以取所有post过来的值
把所有的值放在键值对立面就好了

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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