I have been tasked with translating a java app into asp.net 5 and i am still somewhat new to it (asp.net 5). The following java and javascript (excerpts from the project) work:
javascript:
var connect_xmlhttprequest = new XMLHttpRequest();
connect_xmlhttprequest.open("POST", "tunnel?connect", true);
connect_xmlhttprequest.withCredentials = withCredentials;
addExtraHeaders(connect_xmlhttprequest, extraHeaders);
connect_xmlhttprequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
connect_xmlhttprequest.send(data);
//data ='&WIDTH=1692&HEIGHT=902&DPI=120'
java:
protected void handleRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException {
String query = request.getQueryString();
int h = Integer.valueOf(request.getParameter("HEIGHT"));
int w = Integer.valueOf(request.getParameter("WIDTH"));
}
In the above code, query becomes "connect" and intenger values of the resolutions passed in the xmlhttprequest are pulled and assigned.
In asp.net 5 i'm having trouble. I can get the querystring:
string query = context.Request.QueryString.Value; //gives me "?connect"
string sHeight= request.Query["HEIGHT"].ToString(); //null
string sWidth= request.Query["WIDTH"].ToString(); //null
The above is NOT working. My understanding was that since the encoding of the xmlhttprequest was application/x-www-form-urlencoded then it would put the data passed in the .send() into the url. I've been going through the HttpRequest object but so far have found nowhere that the data sent is located. Any help to understand what's going on here would be greatly appreciated. All thutorials and example I've found with xmlhttprequest and asp.net at all deal with json and righ now I'm trying to convert the java to c# and leave the javascript alone if possible.
My understanding is that asp.net has System.Web which core doesn't have has similar systems such as the params method, but I take it that's not usable in a core app?
Thanks again!