标签: http-post

回发到视图后,值不会改变?

编辑:我已经改变了我的问题和代码,以便更好地澄清我的问题

我有这个(强类型视图)确实使用控制器中为该特定模型提供的值

我想从另一个模型中添加一些模型,在从我的httpPost回复后回复没有任何反应...

提前致谢!

--------------------------------------其他代码更清楚地澄清我的问题--- -

 public class Address
 {
public int Id { get; set;}
public String Name { get; set;}
 }

 public class OtherAddress
 {
public int Id { get; set;}
public String Name { get; set;}
public String City { get; set;}
 }

 public class MasterModel
{
 public Address Address { get; set;}
 public List<OtherAddress> OtherAddressess { get; set;}
 }



 public ActionResult Create()
 {
 MasterModel Model = new MasterModel();
 Model.Person = new Person();
 Model.Address = new Address(); …
Run Code Online (Sandbox Code Playgroud)

http-post asp.net-mvc-3

2
推荐指数
1
解决办法
4245
查看次数

WCF WebInvoke方法POST

我有一个wcf服务,我想测试向它发布数据。但是我函数的参数永远不会得到任何值。

[OperationContract]
[WebInvoke(UriTemplate = "TestPost", Method = "POST", 
        ResponseFormat = WebMessageFormat.Json,
        RequestFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.WrappedRequest)]
int Test(string value);

public int Test(string value)  //Value stays null
{
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我发送的JSON请求是使用Fiddler2构建的

http://localhost:49633/Service1.svc/TestPost

User-Agent: Fiddler
Host: localhost:49633
Content-Length: 42
Content-type: application/json

{"value":{"name":"value","name1":"value"}}
Run Code Online (Sandbox Code Playgroud)

我希望参数包含一个JSON字符串,因此基本上我正在创建一个包含JSON对象的JSON请求,因为我想稍后将JSON对象反序列化为我的自定义对象之一。有什么想法为什么value参数保持为空?

谢谢

wcf json http-post

2
推荐指数
1
解决办法
3万
查看次数

目标c - 通过http POST发送图像

我正在尝试了解如何使用http POST和我当前的客户端 - 服务器协议设计发送图像.从客户端到服务器的所有消息类似于下面的示例,有一个带参数的cmd字符串cmd和一些更相关的命令参数.

例如,这是我向服务器发送文本消息的方式:

- (void)sendMessagesWithText:(NSString *)text fromUser:(NSString *)userId
{
    NSString *url = SERVER_URL;

    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
    [request setURL:[NSURL URLWithString:url]];
    [request setHTTPMethod:@"POST"];

    NSMutableData *body = [NSMutableData data];

    [body appendData:[[NSString stringWithFormat:@"cmd=%@&userid=%@&msgtext=%@", 
                       @"sendmessage", 
                       userId,
                       text] dataUsingEncoding:NSUTF8StringEncoding]];


    [request setHTTPBody:body];

    // send to server
    [[NetworkHelper sharedManager] sendRequest:request]; 
}
Run Code Online (Sandbox Code Playgroud)

现在我想让用户也发送图像,但是如何使用我的协议设计发送它?我应该在cmd字符串后将图像附加到正文吗?

http objective-c http-post nsmutableurlrequest ios

2
推荐指数
1
解决办法
8393
查看次数

Perl - 如何将[a => 1,b => 2,...]等2个数组/列表连接到一个?

我需要加入2个perl数组/列表(抱歉,不知道它们是如何正确命名的)格式

[ a=>1, b=>2, c=>3 ] and [ d=>4, e=>5, f=6 ]
Run Code Online (Sandbox Code Playgroud)

并需要加入他们

[ a=>1, b=>2, c=>3, d=>4, e=>5, f=6 ]
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?我之前从未使用过这样的列表......

我需要HTTP :: Request :: Common

$ua->request(POST 'http://somewhere/foo', [foo => bar, bar => foo]);
Run Code Online (Sandbox Code Playgroud)

因为每个请求都有一组标准参数,另外还有自定义参数,具体取决于请求.当然,我不希望在每个请求中编写相同的内容,而只是定义公共参数一次.

Tnx为你提供帮助,罗伯特

澄清:

这是aprox.我想做的事:

my $result = httpPOST( $url, [ a=>1, b=2, ... ] );

sub httpPOST {
    my( $url, $params ) = @_; # ???
    my $ua = LWP::UserAgent->new;

    my $result  = $ua->request( POST $url, [ %auth, ????? ] );

    return $result->content;
}
Run Code Online (Sandbox Code Playgroud)

嗯......我没有得到合适的语法.请你帮助我一次!?;)

arrays perl http-post httprequest

2
推荐指数
1
解决办法
209
查看次数

将表单提交到没有地址栏的新窗口

此代码将表单提交到新窗口

<form action="..." method="post" target="_new">
Run Code Online (Sandbox Code Playgroud)

但是有可能在没有地址栏的情况下启动新窗口并定义其大小吗?

html forms post http-post target

2
推荐指数
1
解决办法
7935
查看次数

在POST变量中还包括未选中的复选框 - 多个复选框

我在我的php文件中使用下面的代码从多个复选框中获取值.

    if(!empty($_POST['check_list'])) {
        foreach($_POST['check_list'] as $check) {
                update_comment_meta($check, 'consider', 1);
        }


    }
Run Code Online (Sandbox Code Playgroud)

问题是这个代码显然$_POST['check_list']只在数组中放入了检查值.

我需要update_comment_meta通过将'0'作为第三个参数而不是'1'来对未设置的值执行该功能.

有关更多详细信息,我给出了生成HTML表单的代码:

<form action="" id="primaryPostForm" method="POST">

<?php    
         $defaults = array(
    'post_id' => $current_post); 
         $com= get_comments( $defaults );

        foreach ($com as $co) {
    if(get_comment_meta($co->comment_ID, 'consider', true)==1) {
    ?><input type="checkbox" name="check_list[]" value="<?php echo $co->comment_ID; ?>" checked="checked">

    <?php }
    else {
    ?><input type="checkbox" name="check_list[]" value="<?php echo $co->comment_ID; ?>" >
    <?php
    }}
</form>
Run Code Online (Sandbox Code Playgroud)

您的平常帮助总是受到赞赏.

html php wordpress checkbox http-post

2
推荐指数
1
解决办法
3255
查看次数

如何编写MVC Web Api Post方法进行文件上传

我正在按照教程从android上传文件到服务器,但我似乎无法在服务器端获得正确的代码.有人可以帮我编写可以使用android java上传器的Web Api post方法吗?我当前的web api控制器类看起来像这样:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;

namespace WSISWebService.Controllers
{
    public class FilesController : ApiController
    {
        // GET api/files
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/files/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/files
        public string Post([FromBody]string value)
        {
            var task = this.Request.Content.ReadAsStreamAsync();
            task.Wait();
            Stream requestStream = task.Result;

            try
            {
                Stream …
Run Code Online (Sandbox Code Playgroud)

java asp.net-mvc android http-post httprequest

2
推荐指数
1
解决办法
1151
查看次数

如何在android中解析HTML响应

我使用Android中的HttpPost将数据发送到服务器,服务器已成功接收.现在服务器响应如下:

<html><body>
<input type="text" id="nameL" name="nameL" value="Sam" />
<input type="text" id="level" name="level" value="Introductory"  />
</body></html>
Run Code Online (Sandbox Code Playgroud)

如何name在Android客户端上使用输入属性(例如nameL和level)获取http响应的值?我能够获得字符串响应,但它包含<html>....</html>一个字符串中的所有标记(如上所示).

android httpresponse http-post androidhttpclient

2
推荐指数
1
解决办法
4377
查看次数

HTTP Post Request:错误400,Firebase主题消息

我正在尝试在Android应用程序中实现Firebase主题消息,我​​正在尝试构建一个HTTP post请求,并且我收到的响应代码为400.我已经查看了各种解决方案,但它们似乎都没有救命.

这是我调用AsyncTask的子类的地方:

try{new FirebaseSendMessage().execute("Hello world");}
                catch (Exception e) {
                    Log.d("Exception", e.toString());
                }
Run Code Online (Sandbox Code Playgroud)

这是我的Async Task类的子类.

class FirebaseSendMessage  extends AsyncTask<String, Integer, Double> {
private final static String USER_AGENT = "Mozilla/5.0";
private final static String AUTH_KEY = "<My firebase authorization key obtained from firebase>";

private Exception exception;

protected Double doInBackground(String... params) {
    try {
        sendRequest(params);
    } catch (Exception e) {
        this.exception = e;
    }
    return null;
}

protected void onPostExecute(Long l) {
    // TODO: check this.exception
    // TODO: do something with the …
Run Code Online (Sandbox Code Playgroud)

android http http-post firebase firebase-cloud-messaging

2
推荐指数
1
解决办法
1万
查看次数

使用经典ASP VBScript时无法获取原始POST数据

我已经尝试了两天来设置满足第三方提供商要求的端点。他们将通过HTTPS POST向我们发送有关业务对象状态的更新,请求的内容将为JSON。不幸的是,它现在必须用VBScript编写。

目前,我无法获得他们发送给我的请求的原始内容,因此我根本无法处理它。

我创建了一个简单的终结点(raw-form.asp)和两个测试页来演示该问题。首先,我使用HTML表单设置了一个简单的测试HTML页面(raw-form-test1.asp),它可以正常工作。第二个测试页(raw-form-test2.asp)使用将内容发送到端点WinHttpRequest。使用此功能时,数据不存在。我正在尝试通过进行获取Request.Body

原始形式的asp:

<%
    Dim post : post = Request.Body
    Response.ContentType = "text/plain"
    Response.Write "Your " & Request.ServerVariables("REQUEST_METHOD") & " data was: " & post
%>
Run Code Online (Sandbox Code Playgroud)

raw-form-test1.asp:

<!DOCTYPE html>
<html>
    <body>
        <form action="raw-form.asp" method="post">
            <p><textarea name="data"></textarea></p>
            <p><input type="submit"></p>
        </form>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

raw-form-test2.asp:

<%
    Dim data : data = Request.Form("data")
    Dim resp : resp = ""

    If data <> "" Then
        Dim http : Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
        http.Open "post", "http://localhost:8080/raw-form.asp"
        http.Send data
        http.WaitForResponse(10)
        resp …
Run Code Online (Sandbox Code Playgroud)

vbscript http-post asp-classic

2
推荐指数
1
解决办法
3813
查看次数