Asp.ne与Java

java 发送post 的请求

package com.silence;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.HttpURLConnection;
import java.net.ProtocolException;
import java.net.URL;
import java.util.List;
import java.util.Map;

public class another {
	
    //发送post请求
	public static String sendPost(String param) throws IOException
	{
	String reqUrl = "http://172.28.146.36/requestDemo/"+param+".aspx";
	
	
	URL url = new URL(reqUrl);
	HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
    httpConn.setDoInput(true);
    httpConn.setDoOutput(true);
    httpConn.setUseCaches(false);
    httpConn.setConnectTimeout(10000000);
    httpConn.setReadTimeout(100000);
    // 2、设置请求头
    httpConn.setRequestProperty("User-Agent",
            "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727)");
    //System.out.println("request url : " + reqUrl);
   
    // 3、连接
	httpConn.setRequestMethod("POST");
	
    httpConn.connect();
    
 // 4、设置请求参数
    OutputStream outStream = httpConn.getOutputStream();
    String postData = "{\"command\":{\"header\":{\"Name\":\"REQUKEY\"wwww"; //"jsonData={\"command\":{\"header\":{\"Name\":\"REQUKEY\"wwww"

    PrintStream ps = new PrintStream(outStream);
    ps.print(postData);

    String result="";
    BufferedReader  in = new BufferedReader(
    		new InputStreamReader(httpConn.getInputStream()));
    		String line;
    		while ((line = in.readLine())!= null)
    		{  
    		result +=line;
    		}
  //System.out.println(result);
  return result;	
	}
	
	public static void main(String[] args) throws IOException {
		String param = "twsfs011";
//		String choice = sendPost(param);
//		param = select(choice);
		String  res= sendPost(param);
		System.out.println(res);
	}
}

C# 处理匿名字符串

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace requestDemo
{
    public partial class twsfs011 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string data = null;
            for (int i = 0; i < Request.Params.Count; i++)
            {  //取出所有的字符然后搜索
              //Response.Write( Request.Params[i].ToString());
              data += Request.Params[i].ToString();  
            }
            
            //string data = Request.Form["jsonData"].ToString().Trim();
            string requestType = control.select(data);
            Response.Redirect(requestType + ".aspx");
        }
    }
}

another: 

1 服务器活返回所有的字符串,如果没有<html标签>

2 IIS目录下的80端口抢占会出现问题

3 https的安装,网站邮件属性可以选择是否使用https

4 IIS 位置,控制面板-->管理工具-->internet管理工具,默认文件夹为 c:inetpub

你可能感兴趣的:(Asp.ne与Java)