本文整理汇总了C#中System.Web.HttpContext.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContext.ToString方法的具体用法?C# HttpContext.ToString怎么用?C# HttpContext.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpContext
的用法示例。
在下文中一共展示了HttpContext.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequest
public void ProcessRequest(HttpContext context)
{
Log.WriteDebug("ProcessRequest start");
try
{
Stream stream = context.Request.InputStream;
byte[] byteArray = new byte[stream.Length];
stream.Read(byteArray, 0, (int)stream.Length);
string postXmlStr = System.Text.Encoding.UTF8.GetString(byteArray);
Log.WriteDebug("1");
if (!string.IsNullOrEmpty(postXmlStr))
{
Log.WriteDebug("IsNullOrEmpty");
XmlDocument doc = new XmlDocument();
doc.LoadXml(postXmlStr);
if (string.IsNullOrWhiteSpace(sToken))
{
Log.WriteDebug("string.IsNullOrWhiteSpace(sToken)");
DataTable dt = ConfigDal.GetConfig(WXMsgUtil.GetFromXML(doc, "ToUserName"));
DataRow dr = dt.Rows[0];
sToken = dr["Token"].ToString();
sAppID = dr["AppID"].ToString();
sEncodingAESKey = dr["EncodingAESKey"].ToString();
Log.WriteDebug(sToken + "\r\n" + sAppID + "\r\n" + sEncodingAESKey + "\r\n");
}
Log.WriteDebug("2");
if (!string.IsNullOrWhiteSpace(sAppID)) //没有AppID则不解密(订阅号没有AppID)
{
Log.WriteDebug("!string.IsNullOrWhiteSpace(sAppID)");
//解密
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(sToken, sEncodingAESKey, sAppID);
string signature = context.Request["msg_signature"];
string timestamp = context.Request["timestamp"];
string nonce = context.Request["nonce"];
Log.WriteDebug(signature + "\r\n" + timestamp + "\r\n" + nonce + "\r\n");
string stmp = "";
int ret = wxcpt.DecryptMsg(signature, timestamp, nonce, postXmlStr, ref stmp);
if (ret == 0)
{
doc = new XmlDocument();
doc.LoadXml(stmp);
try
{
Log.WriteDebug("3");
responseMsg(context, doc);
}
catch (Exception ex)
{
//FileLogger.WriteErrorLog(context, ex.Message);
Log.WriteError(ex.Message);
}
}
else
{
//FileLogger.WriteErrorLog(context, "解密失败,错误码:" + ret);
Log.WriteError("解密失败,错误码:" + ret);
}
}
else
{
Log.WriteDebug("responseMsg(context, doc);");
responseMsg(context, doc);
}
}
else
{
Log.WriteError("valid(context);");
valid(context);
}
}
catch (Exception ex)
{
//FileLogger.WriteErrorLog(context, ex.Message);
Log.WriteError("ProcessRequest" + context.ToString() + ex.Message);
}
}