我想知道是否有人可以帮助$_POST再次发布价值.假设我将表单值发布到post.php,我可以通过$ _POST或$ _REQUEST变量访问数据.但是如何将$ _POST发布到另一个url让我们说post_one.php并在那里访问数据?
我正在将视图从[HttpPost]方法重定向到[HttpGet]方法.我已经开始工作,但想知道这是否是最好的方法.
这是我的代码:
[HttpPost]
public ActionResult SubmitStudent()
{
StudentViewModel model = TempData["model"] as StudentResponseViewModel;
TempData["id"] = model.Id;
TempData["name"] = model.Name;
return RedirectToAction("DisplayStudent");
}
[HttpGet]
public ActionResult DisplayStudent()
{
ViewData["id"] = TempData["id"];
ViewData["name"] = TempData["name"];
return View();
}
Run Code Online (Sandbox Code Playgroud)
视图:
<%@ Page
Language="C#"
Inherits="System.Web.Mvc.ViewPage"
%>
<html>
<head runat="server">
<title>DisplayStudent</title>
</head>
<body>
<div>
<%= ViewData["id"]%> <br />
<%= ViewData["name"]%>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 其实我的问题很简短.
如何从ASP.NET Web API POST或PUT获取HttpPostedFile?
我确实看到我可以从请求中获取各种信息,如Request.Header,Request.Content,Request.Properties.在哪里可以找到我传递的文件,如何从中创建HttpPostedFile?
提前致谢!
我需要创建一个Rails应用程序,该应用程序将接受来自移动客户端的Post请求并存储随请求发送的信息.我将使用Ajax发送请求.使用以下参数发送请求:latitude(float)经度(float)时间戳(Javascript Date对象)
我已经使用rails generate resource创建了一个包含相应字段的数据模型,但我不确定如何让Rails接受Post请求并创建一个包含必要信息的对象.我应该如何编辑生成的代码Rails以实现此目的?
谢谢,我为提出这样一个基本问题而道歉.
所以标题表明我的问题是得到了我正在制作的HTTP POST的响应.应该发生的是我发送了一堆变量,PHP检查数据库,然后向我发送结果(作为页面的回显).
这是android代码:
public class CheckChallenge extends AsyncTask<String, Void, String>
{
@Override
protected String doInBackground(String... urls)
{
String response = "";
try
{
URL = urls[0];
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(4);
nameValuePairs.add(new BasicNameValuePair("victim",NetPlay.myId));
// need to return these to an array
nameValuePairs.add(new BasicNameValuePair("rival",rivalid));
nameValuePairs.add(new BasicNameValuePair("word","null"));
nameValuePairs.add(new BasicNameValuePair("won","0"));
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://www.hanged.comli.com/check-rival.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse execute = httpclient.execute(httppost);
HttpEntity entity = execute.getEntity();
//InputStream is = entity.getContent();
//mText.setText(is.toString());
Log.i("postData", execute.getStatusLine().toString());
//HttpEntity entity = response.getEntity();
}
catch(Exception …Run Code Online (Sandbox Code Playgroud) 我试图通过使用其API页面上列出的Reddit API - POST登录端点来访问我的Reddit用户帐户.
我试过这个:
curl -i -X POST -d '{"user":"myusername", "passwd":"mypassword", "rem":"true" }' http://www.reddit.com/api/login
Run Code Online (Sandbox Code Playgroud)
但它说错误的密码(我使用相同的凭据登录到网站,所以我不知道什么是错的):
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
{
"jquery":
[[0, 1, "call", ["body"]], [1, 2, "attr", "find"],
[2, 3, "call", [".status"]], [3, 4, "attr", "hide"],
[4, 5, "call", []], [5, 6, "attr", "html"],
[6, 7, "call", [""]], [7, 8, "attr", "end"],
[8, 9, "call", []], [0, 10, "attr", "find"],
[10, 11, "call", [".error.WRONG_PASSWORD.field-passwd"]],
[11, 12, "attr", "show"], [12, 13, "call", []],
[13, 14, …Run Code Online (Sandbox Code Playgroud) 我已经创建了一个ASP.Net API控制器,我正在尝试使用Angular发出POST请求.请求到达我的控制器方法,但参数值为null.
我的角色代码:
$http({ method: 'POST', url: '/api/Contents', data: "value=foobar", headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).
success(function(data) {
}).
error(function(data, status, headers, config) {
});
Run Code Online (Sandbox Code Playgroud)
我也试过json(Json是我最想要的):
$http({ method: 'POST', url: '/api/Contents', data: { "foo": "bar", "foo2": "bar2" }, headers: { 'Content-Type': 'application/json'} }).
success(function(data) {
}).
error(function(data, status, headers, config) {
});
Run Code Online (Sandbox Code Playgroud)
我的(非常简单)Controller方法如下所示:
public void Post([FromBody]string value)
{
//But Value is NULL!!!!!!
}
Run Code Online (Sandbox Code Playgroud)
以下是我从Chrome中删除的请求标题中的一些值(我认为可能很有趣:
我错过了什么?
我在我的android应用程序中发了一个HTTP帖子.值从我的应用程序发送到我的网络服务器.问题是,这些值不是我想要的UTF-8.我的网络服务器有UTF-8编码,所以我知道我的应用程序中有代码需要更改.请参阅下面的我的代码段:
private void sendPostRequest(String facebookId, String name, String email) {
class SendPostReqAsyncTask extends AsyncTask<String, Void, String>{
@Override
protected String doInBackground(String... bcs) {
String bcFacebookId = bcs[0];
String bcName = bcs[1];
String bcEmail = bcs[2];
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("URL");
BasicNameValuePair facebookIdBasicNameValuePair = new BasicNameValuePair("bcFacebookId", bcFacebookId);
BasicNameValuePair nameBasicNameValuePair = new BasicNameValuePair("bcName", bcName);
BasicNameValuePair emailBasicNameValiePair = new BasicNameValuePair("bcEmail", bcEmail);
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
nameValuePairList.add(facebookIdBasicNameValuePair);
nameValuePairList.add(nameBasicNameValuePair);
nameValuePairList.add(emailBasicNameValiePair);
try {
UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(nameValuePairList);
httpPost.setEntity(urlEncodedFormEntity);
try { …Run Code Online (Sandbox Code Playgroud) 我的JavasSript发送请求:
var jax = new XMLHttpRequest();
jax.open("POST", "http://localhost/some.php", true);
jax.setRequestHeader("Content-Type", "application/json");
jax.send(JSON.stringify(jsonObj));
jax.onreadystatechange = function() {
if(jax.readyState === 4) { console.log(jax.responseText); }
}
Run Code Online (Sandbox Code Playgroud)
现在我所有的PHP都是:
print_r($HTTP_RAW_POST_DATA);
print_r($_POST);
Run Code Online (Sandbox Code Playgroud)
原始发布数据的输出是对象字符串,但是post数组是空的.
{"name" : "somename", "innerObj" : {} ... }
Array
(
)
Run Code Online (Sandbox Code Playgroud)
我需要以适当的格式获取$_POST变量,而jquery不是一个选项.
我有以下基本代码用于发布plsql json请求.被执行的web服务没有任何响应,因为它只是用于执行某项任务.但每次执行块时,我都会从Apache Tomcat获取状态码400.我哪里错了?
declare
http_resp utl_http.resp;
http_req utl_http.req;
json_msg VARCHAR2(500);
begin
http_req := utl_http.begin_request('http://192.168.1.194:8080/NotificationApp/sendNotification.rest', 'POST');
utl_http.set_body_charset(http_req, 'UTF-8');
utl_http.set_header(http_req, 'Content-Type', 'application/json');
json_msg := '{"code":100,"id": "APA91bFSmD_gBsUwP_hraRZL20mt8p4ejGn5fC7tlciINT50Ad8oIod2T-64GVk_8rrjoqXGEpYuRcoQogG0L7aOKIjeeisTcmHiUUONbnZzn4_u0ED7QD_iNeVkh2RU8Pa-HBHwgJUgOT-TyvlM9hB4Yn9fvWER","data": "alert alert"}';
utl_http.write_text(http_req, dbms_lob.substr(json_msg,dbms_lob.getLength(json_msg),1));
http_resp := utl_http.get_response(http_req);
if (http_resp.status_code >= 400) and
(http_resp.status_code <= 499)
then
dbms_output.put_line(http_resp.status_code);
end if;
utl_http.end_response(http_resp);
end;
Run Code Online (Sandbox Code Playgroud)
提前致谢