简体   繁体   English

从Android的ASPX页面获取响应

[英]Get Response Back from ASPX page in Android

I have an Android application that makes a call to an ASPX page on a server, which does some database work and return fine (most of the time). 我有一个Android应用程序,该服务器调用服务器上的ASPX页面,该服务器完成一些数据库工作并返回正常(大部分时间)。 However, I would like to have some verification that process executed fine. 但是,我想验证一下该过程是否正常执行。 Hence I put the following line in my ASPX code after which the Sub Ends. 因此,我在ASPX代码中添加了以下行,之后Sub结束了。

Response.AddHeader(CONFIG.REG_RESPONSE, CONFIG.REG_ADDED)

And these lines in my Android 这些行在我的Android中

OutputStream out = httpCon.getOutputStream();
out.write(bytes);
out.close();
int status = httpCon.getResponseCode();
strReceivedURL = httpCon.getURL().getFile();
strReturnedResponse = httpCon.getHeaderField(Config.REG_RESPONSE);    
Log.d(DEBUG, "Response Header:" + strReturnedResponse);

However, it returns null. 但是,它返回null。 Also, sorry for this stupid question, but if I put 另外,很抱歉这个愚蠢的问题,但是如果我把

Response.Redirect("/") 'Redirecting to home page

would it case Response.Header(s) to be null? 会否将Response.Header(s)设置为null? What is the best way to handle requests like these? 处理此类请求的最佳方法是什么? I am using an ASPX page (just like a Servlet), and this aspx page has no HTML in it. 我正在使用ASPX页面(就像Servlet),并且此aspx页面中没有HTML。

I believe you need to place that line at the top of your page 我相信您需要将该行放在页面顶部

Response.AddHeader(CONFIG.REG_RESPONSE, CONFIG.REG_ADDED)

oh and do not redirect, this will cause unexpected behavior 哦, 重定向,这会导致意外的行为

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM