只有一个Default.aspx文件,根据不同的Request["action"]显示不同的内容,先转到文件管理页面,然后在某个文件/文件夹背后的"重命名"链接处点击,弹出个新页面,此时在新页面的一TextBox中能看到文件/文件夹的名字,修改内容,再点下新页面的一个Button,重命名完毕,关闭新页面。回到原来的那个文件管理页面,刷新一下能看见重命名成功。问题就出在:对文件重命名成功后,一切操作正常,但是对文件夹重命名成功后,再次点文件/文件夹后面的"重命名"链接,结果新页面显示登陆页面,也就是Session["Logged"] == null,为什么会这样呢?
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Logged"] == null)
{
ShowLogin();
}
else
{
//...
if (!Page.IsPostBack)
{
switch (Request["action"].ToString())
{
//...
case "rename":
ShowRn(Request["src"]);
break;
//....
}
}
}
}
protected void ShowFolders(string strFPath) // 文件管理页面,显示文件夹里子文件夹、文件,并跟上对应的操作功能链接
{
//...
lbl_Files.Text += "<a href='?action=rename&src=" + dirPath + "' target='_blank'>重命名</a>|";
//...
lbl_Files.Text += "<a href='?action=rename&src=" + filePath + "' target='_blank'>重命名</a>|";
//...
}protected void ShowRn(string strPath)
{
//...
pnl_FileDirRename.Visible = true; // 重命名页面只显示一个txB_FileDirRen(TextBox)和一个btn_FileDirRen(Button)
if (strPath[strPath.Length - 1] != '\\')
{
txB_FileDirRen.Text = Path.GetFileName(strPath); // 显示要被重命名的文件名
}
else
{
strPath = strPath.Substring(0, strPath.Length - 1); // 去掉最后的'\\'
txB_FileDirRen.Text = strPath.Substring(strPath.LastIndexOf("\\") + 1);// 再取最后一段名字,显示要被重命名的文件夹名
}
}protected void btn_FileDirRen_Click(object sender, EventArgs e) // 文件重命名,完了后自动关闭
{
//...
if (strPath[strPath.Length - 1] != '\\')
{
File.Move(strPath, Directory.GetParent(strPath) + "\\" + txB_FileDirRen.Text);
}
else
{
Directory.Move(strPath.Substring(0, strPath.Length - 1), Directory.GetParent(strPath.Substring(0, strPath.Length - 1)) + "\\" + txB_FileDirRen.Text);
}
Response.Write("<script>alert('Rename Success! Please refresh')</script>");
Response.Write("<script>window.open('', '_self');window.close()</script>");
//...
}请回帖的朋友注意:SessionState只能是InProc,不要试图修改WebConfig之类的东西,我只有一个*.aspx文件,几天解决不了这个问题,我真想知道问题的根源。
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Logged"] == null)
{
ShowLogin();
}
else
{
//...
if (!Page.IsPostBack)
{
switch (Request["action"].ToString())
{
//...
case "rename":
ShowRn(Request["src"]);
break;
//....
}
}
}
}
protected void ShowFolders(string strFPath) // 文件管理页面,显示文件夹里子文件夹、文件,并跟上对应的操作功能链接
{
//...
lbl_Files.Text += "<a href='?action=rename&src=" + dirPath + "' target='_blank'>重命名</a>|";
//...
lbl_Files.Text += "<a href='?action=rename&src=" + filePath + "' target='_blank'>重命名</a>|";
//...
}protected void ShowRn(string strPath)
{
//...
pnl_FileDirRename.Visible = true; // 重命名页面只显示一个txB_FileDirRen(TextBox)和一个btn_FileDirRen(Button)
if (strPath[strPath.Length - 1] != '\\')
{
txB_FileDirRen.Text = Path.GetFileName(strPath); // 显示要被重命名的文件名
}
else
{
strPath = strPath.Substring(0, strPath.Length - 1); // 去掉最后的'\\'
txB_FileDirRen.Text = strPath.Substring(strPath.LastIndexOf("\\") + 1);// 再取最后一段名字,显示要被重命名的文件夹名
}
}protected void btn_FileDirRen_Click(object sender, EventArgs e) // 文件重命名,完了后自动关闭
{
//...
if (strPath[strPath.Length - 1] != '\\')
{
File.Move(strPath, Directory.GetParent(strPath) + "\\" + txB_FileDirRen.Text);
}
else
{
Directory.Move(strPath.Substring(0, strPath.Length - 1), Directory.GetParent(strPath.Substring(0, strPath.Length - 1)) + "\\" + txB_FileDirRen.Text);
}
Response.Write("<script>alert('Rename Success! Please refresh')</script>");
Response.Write("<script>window.open('', '_self');window.close()</script>");
//...
}请回帖的朋友注意:SessionState只能是InProc,不要试图修改WebConfig之类的东西,我只有一个*.aspx文件,几天解决不了这个问题,我真想知道问题的根源。
我在web.Config里加上的<system.web>
<sessionState cookieless="false" />
</system.web>虽然没报错,但是不能解决问题。
0 或大于 2 这是默认行为。 为每个子目录应用程序将创建一个对象,它将监视该子目录。
1 应用程序将禁用文件更改通知 (FCNs)。
2 应用程序将创建一个对象,以监视主目录。 应用程序将使用此对象来监控每个子目录。