标签: http-post

调用Controller Post方法时遇到麻烦

这是我的方法

    [AcceptVerbs(HttpVerbs.Post)]
    public void SaveImage(FormCollection formValues)
    {
        byte[] contents = Convert.FromBase64String(Request.Form["file"]);
        System.IO.File.WriteAllBytes(Server.MapPath(Request.Form["name"]), contents);
    }
Run Code Online (Sandbox Code Playgroud)

它将从此actionscript方法发布到:

    public function encodeAndSave(e:MouseEvent = null):void
    {
        var date:Date = new Date();
        var by:ByteArray = PNGEnc.encode(canvas.main_bdata);
        var req:URLRequest = new URLRequest(server_path+"Home/SaveImage");
        var params:URLVariables = new URLVariables();
        params.file = Base64.encodeByteArray(by);
        params.name = "MyImage.png";
        req.method = URLRequestMethod.POST;
        req.data = params;
        var ldr:URLLoader = new URLLoader(req);

        ldr.addEventListener(Event.COMPLETE, complete);

        ldr.load(req);

        function complete(e:Event):void
        {
            navigateToURL(new URLRequest("?" + Math.random()), "_self");

        }

    }
Run Code Online (Sandbox Code Playgroud)

但是当encodeAndSave方法运行时,没有文件保存到服务器......

有谁知道如何判断SaveImage方法是否已运行?另外,当我在地址栏中键入:http: //www.mysite.com/Home/SaveImage时,它会显示"无法找到资源".

任何人都有任何想法,为什么它会这样做或我能做些什么来试图找出它?

如果您需要更多信息,请告诉我,我会更新我的问题.

谢谢,
马特

asp.net-mvc file-io controller http-post actionscript-3

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

使用jquery在ASP.NET MVC中进行异常管理

我有2个问题,在第一个问题中,我得到一个列表,我想如果C#代码(控制器)中的例外情况有可能出现一个View(一个错误视图)并显示一个特定的div.如何在.error中获取视图.?HTML

<div><a href="#" class="MnuCustomerList">List</a></div>
Run Code Online (Sandbox Code Playgroud)

jQuery的

$(".MnuCustomerList").click(function () {
    var jqxhr = $.post("/Customer/List", function (data) {
        $('#rightcolumn').html(data);
    })
    .success(function () { alert("success"); })
    .error(function () { alert("error"); })
    .complete(function () { alert("complete"); });
})
Run Code Online (Sandbox Code Playgroud)

;

控制器:

public PartialViewResult List()
{
    throw new Exception("myexception");
    return PartialView("List");
}
Run Code Online (Sandbox Code Playgroud)

第二个问题:我有一个表格

@model MyModel
@using (Html.BeginForm("Save", "Customer", FormMethod.Post))
{
    <table style="width:100%;">
    <tr>
        <td>Code</td>
        <td>@Html.TextBoxFor(m => m.Customer.Code, new { id = "tbCode" })</td>
    </tr>
    <tr>
        <td>LastName</td>
        <td>@Html.TextBoxFor(m => m.Customer.LastName, new { id = "tb", maxlength = 50, …
Run Code Online (Sandbox Code Playgroud)

javascript jquery http-post jquery-validate asp.net-mvc-2

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

将30个变量从客户端发布到服务器的最佳方法是什么?

嘿,我有大约30个由用户创建和修改的变量(没有一个来自输入,因此提交表单实际上不是一个选项),一旦修改完成JS函数处理变量和配偶将它们发布到控制器然后将其发送到模型.

现在,正如标题中所示,我的问题是我发送它们的最佳方式是什么?

时间和注意力,Ido

javascript php client-server http-post

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

使用Jquery传递隐藏的字段值

我有正常的hidden Input field生成方式random string.我需要将其附加到我尝试将数据发布到另一个页面的URL.

我做到了这一点,效果很好.

url:'Upload.html?field1=newvalue',

这是我隐藏的输入字段

<input type="hidden" id="randomdirectory"/>
Run Code Online (Sandbox Code Playgroud)

现在不是newvaluequery string我需要通过我的random directory value.

ajax jquery http-post query-string

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

改造SocketTimeoutException - 上传图片

我目前正在使用Retrofit for Android作为我的网络通信.在向我的后端服务器发送映像时,服务器正处于上载过程中,然后使用SocketTimeoutException进行"超时"改造.

我添加了OKhttp库,正如一些人建议的那样,仍然会得到超时.

目前的img大小约为750kb,因为我已将它们缩小了.

是否有适当的方法来改变改造超时之前的时间量?或者有更好的方法将图像上传到服务器?

谢谢

android http-post retrofit

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

在android中通过http post方法发送json对象

已提供的NOT DUPLICATE.Link是旧版本."http客户端"已在api23中删除

我想发送json对象:

{"emailId":"ashish.bhatt@mobimedia.in","address":"Naya bans","city":"Noida","pincode":"201301","account_number":"91123546374208","bank_name":"Axis Bank","branch_name":"91123546374208","ifsc_code":"UTI0000879"}
Run Code Online (Sandbox Code Playgroud)

到网址:

http://10digimr.mobimedia.in/api/mobile_retailer/update_profile 我该怎么办?通过邮政方式?

方法:

 POST /api/mobile_retailer/update_profile
Run Code Online (Sandbox Code Playgroud)

强制关键:

{"emailId","address"}
Run Code Online (Sandbox Code Playgroud)

请求JSON:

{"emailId":"ashish.bhatt@mobimedia.in","address":"Naya bans","city":"Noida","pincode":"201301","account_number":"91123546374208","bank_name":"Axis Bank","branch_name":"91123546374208","ifsc_code":"UTI0000879"}
Run Code Online (Sandbox Code Playgroud)

响应:

{"message":"Mail Send","data":true,"status":200}
Run Code Online (Sandbox Code Playgroud)

android json http-post httprequest httpurlconnection

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

如何从Android发送http post请求?

我是android的新手,现在我已经厌倦了搜索关于android HTTP请求的最佳教程.

我正在尝试将这些参数发送到phpServer,

  • 名字="某个名字"

  • email ="一些电子邮件"

我们可以在MainActivity.java文件中执行此操作吗?这需要任何jar(库)文件吗?欢迎任何建议.

我试过这个,

@Override
public void onClick(View view) {
    if(view == btnSubscribe){
        HttpURLConnection client = null;
        try {
            URL url = new URL("http://www/somewebsite.com/API/SUBSCRIBE");
            client = (HttpURLConnection) url.openConnection();
            client.setRequestMethod("POST");
            client.setRequestProperty("name","test one");
            client.setRequestProperty("email","text@gmail.com");
            client.setDoOutput(true);

            OutputStream outputPost = new BufferedOutputStream(client.getOutputStream());
            outputPost.flush();
            outputPost.close();
            client.setChunkedStreamingMode(0);

        } catch(MalformedURLException error) {
            showError("Handles an incorrectly entered UR");
        }
        catch(SocketTimeoutException error) {
            showError("Handles URL access timeout");
        }
        catch (IOException error) {
            showError("Handles input and output errors");
        }finally {
            if(client != null)
            client.disconnect();
        }
    } …
Run Code Online (Sandbox Code Playgroud)

php android http-post

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

Angular 2 http post null Web Api Core

我正在使用现有的Web Api(ASP.NET Core)在角度2中实现一个新的Web应用程序,但我遇到了HTTP Post的问题.在搜索了所有类型的信息之后,我仍然无法解决这个问题,我的Web API仍然从角度帖子接收空参数.

我需要看看这里有什么问题.这是我的Angular 2代码:

   posted(event) {
 @Injectable()
export class httpTestComponent {

constructor(public http: Http) {

};

posted(event) {
    var user: UserViewModel = {
        name: "angularUser",
        password: "pw",
        email: "angularMail"
    }
    let pedido = JSON.stringify(user);

    let headers = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers });

    this.http.post('http://localhost:10832/api/Account/Register', { pedido }, options)
        .map(this.extractData).catch(this.handleError).subscribe();
};
Run Code Online (Sandbox Code Playgroud)

视图模型:

export interface UserViewModel {
name: string,
password: string,
email: string,
Run Code Online (Sandbox Code Playgroud)

}

Web API:

 [HttpPost]
    [Route("Register")]
    public void Register([FromBody] UserRegisterViewModel …
Run Code Online (Sandbox Code Playgroud)

javascript asp.net http-post asp.net-web-api angular

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

如何使用HTTP post方法发送位图

我想用HTTP POST方法发送位图图像.如何将其发送到URL?

我使用的是Indy 10和Delphi 10.1.在一个过程中,我创建了一个TStringList包含所有参数值,但我不知道如何传递位图数据.

这是我的代码:

procedure TuDm_Athlos.AddComandaInsertLogo(workList: TStringList;
  imageStream: TStream);
var
  image : TBitmap;
begin
  try
    image := TBitmap.Create;
    imageStream := TStream.Create;
    image.LoadFromFile('D:\\COFEE.BMP');
    image.SaveToStream(imageStream);
    workList.Add('db=titles');
    workList.Add('line_1=');
    worklist.Add('line_2=');
    workList.Add('line_3=');
    workList.Add('line_4=');
    workList.Add('line_5=');
    workList.Add('line_6=');
    workList.Add('store=&DB=PRN_UDG');
    workList.Add('code=1');
    workList.Add('width=' + IntToStr(image.Width));
    workList.Add('height=' + IntToStr(image.Height));
    workList.Add('length=576');
    workList.Add('store=');
  finally
    FreeAndNil(imageStream);
  end;
end;

function TuDm_Athlos.InsertLogo(imageStream: TStream;
  isFullResponse: Boolean): Boolean;
var
  StrResult     : UTF8String;
  workList      : TStringList;
  ContentStream : TStream;
  image         : TBitmap;
begin
  //Setup;
  Result := False;
  try
    try
      workList          := TStringList.Create;
      ContentStream     := …
Run Code Online (Sandbox Code Playgroud)

delphi indy http-post indy10 delphi-10.1-berlin

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

Rails请求规范发布语法

我似乎对如何在请求规范测试中发出发布请求以测试url不太了解,这是测试代码

RSpec.describe "Certifications", type: :request do
  describe "denies public access" do

    it "for new certification form" do
        get new_certification_path
        expect(response).to redirect_to new_user_session_path
    end

    it "for creating certification" do
        certification_attributes = FactoryGirl.attributes_for :certification 

        expect {
            post "/certifications", { certification: certification_attributes }
        }.to_not change(Certification, :count)

        expect(response).to redirect_to new_user_session_path
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

这给出了错误

  1) Certifications denies public access for creating certification
     Failure/Error: post "/certifications", { certification: certification_attributes }

 ArgumentError:
   unknown keyword: certification
Run Code Online (Sandbox Code Playgroud)

我已经尝试过:certifications => certification_attributes,基本上无法理解如何传递参数。

被测控制器仅向该帖子添加相关方法。

class CertificationsController < ApplicationController
  skip_before_action …
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails http-post rspec-rails

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