文件发布以后前台接收不到后台的传的值

carkiller 2009-06-17 05:41:40
一套程序,在本机用运行没有问题,前台页面可以接受到后台页面传的值,可是发布之后,拿到别的机器上用IIS发布后,前台页面就接收不到值了,很诡异的问题啊,改如何解决啊?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Text;

namespace WebSite.Threshold
{
public partial class ThresholdShow : System.Web.UI.Page
{
public static String StrPar;
public static String StrSwf;
public static String strCode;

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//try
//{
//if (Session["user"].ToString() == "")//判断用户是否为空
//{
// ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "AddScript", "alert('请重新登陆');window.location.href='../Login.aspx';", true);
//}

//else
//{

//测试Session
//Session["OrganCode"] = "";
strCode = "";


strCode = Session["OrganCode"].ToString();

Session["Droplist"] = "";

//测试
try
{
//string strCode = Session["OrganCode"].ToString();
strCode = Request.QueryString["Code"].ToString();
}
catch
{
strCode = Session["OrganCode"].ToString();
}

//显示地图flash
if (strCode == "0")//测试用,全国代码为0
{
StrSwf = "FlashVars.swf";
}
else
{
StrSwf = "FlashVars_" + strCode.Substring(0, 2) + ".swf";
}

//显示全国地图报警类型
if (Session["Drop"].ToString() == "0")
{
ddlType.SelectedIndex = 0;
FlashShow("Past24ProblemsCount", strCode);
}
else if (Session["Drop"].ToString() == "1")
{
ddlType.SelectedIndex = 1;
FlashShow("Past24PatchCount", strCode);
}
else if (Session["Drop"].ToString() == "2")
{
ddlType.SelectedIndex = 2;
FlashShow("Past24PolicyCount", strCode);
}
else if (Session["Drop"].ToString() == "3")
{
ddlType.SelectedIndex = 3;
FlashShow("Past24ErrorCount", strCode);
}
//}

Label1.Text = StrPar;
//}
//catch
//{
// ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "AddScript", "alert('请重新登陆');window.top.location.href='../Login.aspx';", true);

//}
}
}

#region 下拉框
/// <summary>
/// 选择变化
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlType_SelectedIndexChanged(object sender, EventArgs e)
{


if (ddlType.SelectedValue == "0")
{
Session["Drop"] = "0";
//lblShow.Text = "";
//恶意软件
FlashShow("Past24ProblemsCount",strCode);
}
else if (ddlType.SelectedValue == "1")
{
Session["Drop"] = "1";
//lblShow.Text = "";
//有漏洞
FlashShow("Past24PatchCount", strCode);
}
else if (ddlType.SelectedValue == "2")
{
Session["Drop"] = "2";
//lblShow.Text = "";
//策略问题
FlashShow("Past24PolicyCount", strCode);
}
else if (ddlType.SelectedValue == "3")
{
Session["Drop"] = "3";
//lblShow.Text = "";
//报警问题
FlashShow("Past24ErrorCount", strCode);
}
}
#endregion

#region 各类型等级判断
/// <summary>
/// 各类型等级判断
/// </summary>
/// <param name="strvalue">传值</param>
private void FlashShow(string strvalue,string strCodes)
{
BLL.Threshold Thresh = new BLL.Threshold();
SqlDataReader dr = Thresh.Get_RangeExpand(strvalue,strCodes);

BLL.Threshold Thresh2 = new BLL.Threshold();
SqlDataReader dr2 = Thresh2.Get_ThresholdRange();

StringBuilder sb = new StringBuilder();

try
{
if (dr2.Read())
{
while (dr.Read())
{
if (Convert.ToInt32(dr["num"].ToString()) <= Convert.ToInt32(dr2["Lv1"].ToString()))
{
sb.Append("mc_" + dr["code"].ToString() + "=1&");
}
if (Convert.ToInt32(dr2["Lv1"].ToString()) < Convert.ToInt32(dr["num"].ToString()) && Convert.ToInt32(dr["num"].ToString()) <= Convert.ToInt32(dr2["Lv2"].ToString()))
{
sb.Append("mc_" + dr["code"].ToString() + "=2&");
}
if (Convert.ToInt32(dr2["Lv2"].ToString()) < Convert.ToInt32(dr["num"].ToString()) && Convert.ToInt32(dr["num"].ToString()) <= Convert.ToInt32(dr2["Lv3"].ToString()))
{
sb.Append("mc_" + dr["code"].ToString() + "=3&");
}
if (Convert.ToInt32(dr2["Lv3"].ToString()) < Convert.ToInt32(dr["num"].ToString()) && Convert.ToInt32(dr["num"].ToString()) <= Convert.ToInt32(dr2["Lv4"].ToString()) || Convert.ToInt32(dr2["Lv3"].ToString()) < Convert.ToInt32(dr["num"].ToString()))
{
sb.Append("mc_" + dr["code"].ToString() + "=4&");
}

}

}
string strCod = (sb.ToString()).Substring(0, (sb.ToString()).Length - 1);
StrPar = strCod;
}
catch
{
StrPar = "";
}
finally
{
dr.Close();
dr2.Close();
}
}
#endregion

#region 默认显示
/// <summary>
/// 默认显示
/// </summary>
private void DefaultShow()
{
for (int i = 0; i < ddlType.Items.Count; i++)
{
if (ddlType.SelectedValue == "0")
{
FlashShow("Past24ProblemsCount",strCode);
}
if (ddlType.SelectedValue == "1")
{
FlashShow("Past24PatchCount",strCode);
}
if (ddlType.SelectedValue == "2")
{
FlashShow("Past24PolicyCount",strCode);
}
if (ddlType.SelectedValue == "3")
{
FlashShow("Past24ErrorCount",strCode);
}
}
}
#endregion
}
}


前台

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ThresholdShow.aspx.cs" Inherits="WebSite.Threshold.ThresholdShow" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<title></title>
<link href="../css/Style.css" type="text/css" rel="Stylesheet" />
<style type="text/css">
.style1
{
width: 100%;
height:100%;
}
</style>


<!--修正FLASH正确显示代码开始-->
<script language="javascript" type="text/javascript" src="flash.js"></script>
<!--修正FLASH正确显示代码结束-->




</head>
<body style="vertical-align:top;">
<form id="form1" runat="server" method="get">
<div>
<div>
<asp:DropDownList ID="ddlType" runat="server" Width="150px" AutoPostBack="True"
onselectedindexchanged="ddlType_SelectedIndexChanged">
<asp:ListItem Value="0">恶意软件问题</asp:ListItem>
<asp:ListItem Value="1">漏洞问题</asp:ListItem>
<asp:ListItem Value="2">策略部署问题</asp:ListItem>
<asp:ListItem Value="3">警报问题</asp:ListItem>
</asp:DropDownList>
<script type="text/javascript">
//debugger
writeflashhtml("_swf=<%=StrSwf%>", "_width=100%", "_height=90%", "_wmode=transparent", "_quality=high", "_flashvars=<%=StrPar%>");
</script>

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

</div>
<div style="vertical-align:top;">
</div>
</div>
</form>
</body>
</html>


就是 StrPar, 程序发布后就接不到值了,晕死,上礼拜还好好的,这礼拜死活都不行了,大家帮忙找找看,错在哪儿,谢了
...全文
110 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
oo_2008 2009-06-18
  • 打赏
  • 举报
回复
public static String StrPar;
静态变量慎用,它是长期存放在内存中,在页面上面用会出问题的,可能出现一会有值一会没有值的情况
session有时候也会丢失,如果是页面级别的传值可以用ViewState,或赋值给隐藏按钮
carkiller 2009-06-18
  • 打赏
  • 举报
回复
问题解决了,星期天有人改动过我的代码,在数据层的SQL那边有改动,发布后,那边的代码出了问题,我重写了那部分代码,问题解决了,回答得都有分哈,O(∩_∩)O
anheizhizi 2009-06-18
  • 打赏
  • 举报
回复
先把TRY CATCH 去掉,看看是不是异常了。
开发阶段先不要加异常处理,可以及早的发现问题。
V68V6 2009-06-17
  • 打赏
  • 举报
回复
参考链接中有关于匿名类的说明:
http://hi.baidu.com/skydau/blog/item/7b614b4a3da54b2409f7ef2f.html
chen_ya_ping 2009-06-17
  • 打赏
  • 举报
回复
楼主也许是try 中if 或者是While不符合条件,也有可能就是try中发生了异常导致了StrPar没有数据
carkiller 2009-06-17
  • 打赏
  • 举报
回复
取的到得,我放在VS2008里面逐步,或者是浏览,都能取到值的,就是发布以后,在其他机器上用IIS浏览的时候,就没有值了,页面里面放了一个<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>就是用来PO这个值的。
正宗熊猫哥 2009-06-17
  • 打赏
  • 举报
回复
public static String strCode;这个地方直接给个值看看前台能否获取的到
如果可以的话就一步一步跟踪了。应该是哪个地方出错了,有可能是你的SESSION
获取不到那就见鬼了

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧