Session variables disappear in relation to a file upload

M

Matt Jensen

Howdy
I've got a rather strange issue occuring.

I used forms based .NET authentication, although I'm also setting some
session variables when people login.

However, I've found when people use one of my webform pages which includes a
button that pops up a window where you can upload files, if you upload files
in this popup window, it seems to somehow clear out all of the session
variables and the users get logged out. However, if people don't upload
files, then their use of the webform page proceeds as required/expected.

I'm planning to phase out the session variables by upgrading my code,
however I can't understand this problem which seems quite strange and I'd
like to know what the problem is.

Any clues would be greatly appreciated.

Cheers
Matt


If it helps, here is code in question:
The main part of the code behind for the upload page:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack) {
pnlUpload.Visible = true;
pnlUploaded.Visible = false;
}
if (IsPostBack) {
pnlUpload.Visible = false;
pnlUploaded.Visible = true;
}
strJobRequestID = Request.QueryString["JobRequestID"];
btnClose2.Attributes.Add("onclick", "return closeupdate();");


}


public void UploadFile(object Sender,EventArgs E) { //Event handler for
the upload button
lblFileList.Text = "";

if (Request.Files.Count > 0) { //if there are files attached

//Get directory path
string strDirPath = Server.MapPath(".\\" + "/../../detail/files/" +
strJobRequestID + "/");
//Response.Write(strDirPath);

//if Directory path doesn't exist then create it
if (!Directory.Exists(strDirPath)) {
Directory.CreateDirectory(strDirPath);
}

//Iterate through the Request.Files collection
for(IntLoop=0; IntLoop<Request.Files.Count; IntLoop++) {
if (Request.Files[IntLoop] !=null) { //Checking for valid file
// Since the FileName gives the entire path we use Substring function
to get the filename (including the file extension).
string StrFileName =
Request.Files[IntLoop].FileName.Substring(Request.Files[IntLoop].FileName.LastIndexOf("\\")
+ 1);
string StrFileType = Request.Files[IntLoop].ContentType;
int IntFileSize = Request.Files[IntLoop].ContentLength;

//Check for file length > 0 and Upload if it is
if (IntFileSize > 0) {
//Save the file to the web server
string filePath = (strDirPath + "/" + StrFileName);
Request.Files[IntLoop].SaveAs(filePath);
lblFileList.Text += "<li>" + StrFileName + "</li>";
}
}
}

}

}



Here is the main code for the webform. Notice the "multipart/form-data" -
could that be causing the problem somehow?

<form id="JBSv4ServerForm" enctype="multipart/form-data" runat="server">
<div class=JBSv4PopupBody>
<!--begin of body-->
<div class=JBSv4PopupMainBody>
<div class=JBSv4JobListing><asp:panel id=pnlUpload runat="server">
<div class="JBSv4JobListingHeader">
<h3>Attach files to job <%if
(!Request.QueryString["JobRequestID"].StartsWith("Temp"))
{%><%=Request.QueryString["JobRequestID"]%><% } %></h3></div>
<table class="JBSv4JobListingTable">
<tr>
<td><input id="File1" type="file" size="30" name="File1"
runat="server"></td>
<td class="listsTableRight" valign="top" rowspan="5">
<p>Use the 'Browse' buttons to select up to five files, then click
'Upload
files'.</p>
<p>You'll be able to attach more files afterwards if you need
to.</p></td></tr>
<tr>
<td><input id="File2" type="file" size="30" name="File2"
runat="server"></td></tr>
<tr>
<td><input id="File3" type="file" size="30" name="File3"
runat="server"></td></tr>
<tr>
<td><input id="File4" type="file" size="30" name="File4"
runat="server"></td></tr>
<tr>
<td><input id="File5" type="file" size="30" name="File5"
runat="server"></td></tr>
<tr>
<td colspan="2"><input class="formbutton" onclick="closewindow();"
type="button" value="Close window" name="btnCloseWindow">&nbsp;
<asp:button id="CmdUpload" onclick="UploadFile" runat="server"
cssclass="formbutton" text="Upload
files"></asp:button></td></tr></table></asp:panel><asp:panel
id=pnlUploaded runat="server">
<div class="JBSv4JobListingHeader">
<h3>Files attached</h3></div>
<table class="JBSv4JobListingTable">
<tr>
<td>
<p>The following files have been attached:</p>
<ul>
<asp:label id="lblFileList" runat="server"></asp:label></ul>
<p><strong>Please note: </strong>Use the 'Close Window' button below
when
you are finished which will close this window AND refresh the job
attachments list.</p>
<asp:button id="btnClose2" runat="server" cssclass="formbutton" text="Close
window"></asp:button>&nbsp;
<asp:button id="btnAttachMore" runat="server" cssclass="formbutton"
text="Attach more files"></asp:button></td></tr></table></asp:panel></DIV>
<!--end of body--></DIV></DIV></FORM>
 
G

Guest

Hi Matt,

Looks like your appdomain is recycling.

You may check that using Perfmon and application restrats counter to verify
if your appdomain is recycling.

Also, what is the size of the file which causes the issues? Is it each and
every file which causes the session to recycle??

--
Thanks,
Rahul Soni

--->The secret to creativity is knowing how to hide your sources<---



Matt Jensen said:
Howdy
I've got a rather strange issue occuring.

I used forms based .NET authentication, although I'm also setting some
session variables when people login.

However, I've found when people use one of my webform pages which includes a
button that pops up a window where you can upload files, if you upload files
in this popup window, it seems to somehow clear out all of the session
variables and the users get logged out. However, if people don't upload
files, then their use of the webform page proceeds as required/expected.

I'm planning to phase out the session variables by upgrading my code,
however I can't understand this problem which seems quite strange and I'd
like to know what the problem is.

Any clues would be greatly appreciated.

Cheers
Matt


If it helps, here is code in question:
The main part of the code behind for the upload page:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack) {
pnlUpload.Visible = true;
pnlUploaded.Visible = false;
}
if (IsPostBack) {
pnlUpload.Visible = false;
pnlUploaded.Visible = true;
}
strJobRequestID = Request.QueryString["JobRequestID"];
btnClose2.Attributes.Add("onclick", "return closeupdate();");


}


public void UploadFile(object Sender,EventArgs E) { //Event handler for
the upload button
lblFileList.Text = "";

if (Request.Files.Count > 0) { //if there are files attached

//Get directory path
string strDirPath = Server.MapPath(".\\" + "/../../detail/files/" +
strJobRequestID + "/");
//Response.Write(strDirPath);

//if Directory path doesn't exist then create it
if (!Directory.Exists(strDirPath)) {
Directory.CreateDirectory(strDirPath);
}

//Iterate through the Request.Files collection
for(IntLoop=0; IntLoop<Request.Files.Count; IntLoop++) {
if (Request.Files[IntLoop] !=null) { //Checking for valid file
// Since the FileName gives the entire path we use Substring function
to get the filename (including the file extension).
string StrFileName =
Request.Files[IntLoop].FileName.Substring(Request.Files[IntLoop].FileName.LastIndexOf("\\")
+ 1);
string StrFileType = Request.Files[IntLoop].ContentType;
int IntFileSize = Request.Files[IntLoop].ContentLength;

//Check for file length > 0 and Upload if it is
if (IntFileSize > 0) {
//Save the file to the web server
string filePath = (strDirPath + "/" + StrFileName);
Request.Files[IntLoop].SaveAs(filePath);
lblFileList.Text += "<li>" + StrFileName + "</li>";
}
}
}

}

}



Here is the main code for the webform. Notice the "multipart/form-data" -
could that be causing the problem somehow?

<form id="JBSv4ServerForm" enctype="multipart/form-data" runat="server">
<div class=JBSv4PopupBody>
<!--begin of body-->
<div class=JBSv4PopupMainBody>
<div class=JBSv4JobListing><asp:panel id=pnlUpload runat="server">
<div class="JBSv4JobListingHeader">
<h3>Attach files to job <%if
(!Request.QueryString["JobRequestID"].StartsWith("Temp"))
{%><%=Request.QueryString["JobRequestID"]%><% } %></h3></div>
<table class="JBSv4JobListingTable">
<tr>
<td><input id="File1" type="file" size="30" name="File1"
runat="server"></td>
<td class="listsTableRight" valign="top" rowspan="5">
<p>Use the 'Browse' buttons to select up to five files, then click
'Upload
files'.</p>
<p>You'll be able to attach more files afterwards if you need
to.</p></td></tr>
<tr>
<td><input id="File2" type="file" size="30" name="File2"
runat="server"></td></tr>
<tr>
<td><input id="File3" type="file" size="30" name="File3"
runat="server"></td></tr>
<tr>
<td><input id="File4" type="file" size="30" name="File4"
runat="server"></td></tr>
<tr>
<td><input id="File5" type="file" size="30" name="File5"
runat="server"></td></tr>
<tr>
<td colspan="2"><input class="formbutton" onclick="closewindow();"
type="button" value="Close window" name="btnCloseWindow">
<asp:button id="CmdUpload" onclick="UploadFile" runat="server"
cssclass="formbutton" text="Upload
files"></asp:button></td></tr></table></asp:panel><asp:panel
id=pnlUploaded runat="server">
<div class="JBSv4JobListingHeader">
<h3>Files attached</h3></div>
<table class="JBSv4JobListingTable">
<tr>
<td>
<p>The following files have been attached:</p>
<ul>
<asp:label id="lblFileList" runat="server"></asp:label></ul>
<p><strong>Please note: </strong>Use the 'Close Window' button below
when
you are finished which will close this window AND refresh the job
attachments list.</p>
<asp:button id="btnClose2" runat="server" cssclass="formbutton" text="Close
window"></asp:button>
<asp:button id="btnAttachMore" runat="server" cssclass="formbutton"
text="Attach more files"></asp:button></td></tr></table></asp:panel></DIV>
<!--end of body--></DIV></DIV></FORM>
 
M

Matt Jensen

Thanks Rahul

Hmm, application restarts are 807 and Requests Queued is 54,000!!!!

And the error occurred for 1 file of 1KB too.

Actually seems to be the code below that's causing the problem, which
renames the file upload directory from a temporary name to the ID number of
the job request (because the webform page in question is for logging a job,
and the directory path ID number is not known until the job is logged):

//JOB FILES (if they exist)

//Root directory path for JBS job files
string strDirPath = Server.MapPath(".\\" + "/../../detail/files/");
//Response.Write(strDirPath+"<br>");

//New Directory path for logged job files
JBSv4.utils.jbs.v4.utils.utils utilsClass1 = new
JBSv4.utils.jbs.v4.utils.utils();

strLongJobRequestID = utilsClass1.LongJobNumber(intJobRequestID);
string strDirPathJobNo = strDirPath + strLongJobRequestID + "\\";
//Response.Write(strDirPathJobNo+"<br>");

//Directory path used for temporary file storage before JobRequestID
was created
strTempJobRequestID = tbxTempID.Text;
string strDirPathTemp = strDirPath + strTempJobRequestID + "\\";
//Response.Write(strDirPathTemp+"<br>");

//Rename temporary file storage directory (if it exists) to job number
directory
if (Directory.Exists(strDirPathTemp)) {
Directory.Move(strDirPathTemp, strDirPathJobNo);
}

What do I do?

Thanks again for any more help.
Matt


Rahul Soni said:
Hi Matt,

Looks like your appdomain is recycling.

You may check that using Perfmon and application restrats counter to
verify
if your appdomain is recycling.

Also, what is the size of the file which causes the issues? Is it each and
every file which causes the session to recycle??

--
Thanks,
Rahul Soni

--->The secret to creativity is knowing how to hide your sources<---



Matt Jensen said:
Howdy
I've got a rather strange issue occuring.

I used forms based .NET authentication, although I'm also setting some
session variables when people login.

However, I've found when people use one of my webform pages which
includes a
button that pops up a window where you can upload files, if you upload
files
in this popup window, it seems to somehow clear out all of the session
variables and the users get logged out. However, if people don't upload
files, then their use of the webform page proceeds as required/expected.

I'm planning to phase out the session variables by upgrading my code,
however I can't understand this problem which seems quite strange and I'd
like to know what the problem is.

Any clues would be greatly appreciated.

Cheers
Matt


If it helps, here is code in question:
The main part of the code behind for the upload page:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack) {
pnlUpload.Visible = true;
pnlUploaded.Visible = false;
}
if (IsPostBack) {
pnlUpload.Visible = false;
pnlUploaded.Visible = true;
}
strJobRequestID = Request.QueryString["JobRequestID"];
btnClose2.Attributes.Add("onclick", "return closeupdate();");


}


public void UploadFile(object Sender,EventArgs E) { //Event handler for
the upload button
lblFileList.Text = "";

if (Request.Files.Count > 0) { //if there are files attached

//Get directory path
string strDirPath = Server.MapPath(".\\" + "/../../detail/files/" +
strJobRequestID + "/");
//Response.Write(strDirPath);

//if Directory path doesn't exist then create it
if (!Directory.Exists(strDirPath)) {
Directory.CreateDirectory(strDirPath);
}

//Iterate through the Request.Files collection
for(IntLoop=0; IntLoop<Request.Files.Count; IntLoop++) {
if (Request.Files[IntLoop] !=null) { //Checking for valid file
// Since the FileName gives the entire path we use Substring
function
to get the filename (including the file extension).
string StrFileName =
Request.Files[IntLoop].FileName.Substring(Request.Files[IntLoop].FileName.LastIndexOf("\\")
+ 1);
string StrFileType = Request.Files[IntLoop].ContentType;
int IntFileSize = Request.Files[IntLoop].ContentLength;

//Check for file length > 0 and Upload if it is
if (IntFileSize > 0) {
//Save the file to the web server
string filePath = (strDirPath + "/" + StrFileName);
Request.Files[IntLoop].SaveAs(filePath);
lblFileList.Text += "<li>" + StrFileName + "</li>";
}
}
}

}

}



Here is the main code for the webform. Notice the "multipart/form-data" -
could that be causing the problem somehow?

<form id="JBSv4ServerForm" enctype="multipart/form-data" runat="server">
<div class=JBSv4PopupBody>
<!--begin of body-->
<div class=JBSv4PopupMainBody>
<div class=JBSv4JobListing><asp:panel id=pnlUpload runat="server">
<div class="JBSv4JobListingHeader">
<h3>Attach files to job <%if
(!Request.QueryString["JobRequestID"].StartsWith("Temp"))
{%><%=Request.QueryString["JobRequestID"]%><% } %></h3></div>
<table class="JBSv4JobListingTable">
<tr>
<td><input id="File1" type="file" size="30" name="File1"
runat="server"></td>
<td class="listsTableRight" valign="top" rowspan="5">
<p>Use the 'Browse' buttons to select up to five files, then click
'Upload
files'.</p>
<p>You'll be able to attach more files afterwards if you need
to.</p></td></tr>
<tr>
<td><input id="File2" type="file" size="30" name="File2"
runat="server"></td></tr>
<tr>
<td><input id="File3" type="file" size="30" name="File3"
runat="server"></td></tr>
<tr>
<td><input id="File4" type="file" size="30" name="File4"
runat="server"></td></tr>
<tr>
<td><input id="File5" type="file" size="30" name="File5"
runat="server"></td></tr>
<tr>
<td colspan="2"><input class="formbutton" onclick="closewindow();"
type="button" value="Close window" name="btnCloseWindow">
<asp:button id="CmdUpload" onclick="UploadFile" runat="server"
cssclass="formbutton" text="Upload
files"></asp:button></td></tr></table></asp:panel><asp:panel
id=pnlUploaded runat="server">
<div class="JBSv4JobListingHeader">
<h3>Files attached</h3></div>
<table class="JBSv4JobListingTable">
<tr>
<td>
<p>The following files have been attached:</p>
<ul>
<asp:label id="lblFileList" runat="server"></asp:label></ul>
<p><strong>Please note: </strong>Use the 'Close Window' button
below
when
you are finished which will close this window AND refresh the job
attachments list.</p>
<asp:button id="btnClose2" runat="server" cssclass="formbutton"
text="Close
window"></asp:button>
<asp:button id="btnAttachMore" runat="server" cssclass="formbutton"
text="Attach more
files"></asp:button></td></tr></table></asp:panel></DIV>
<!--end of body--></DIV></DIV></FORM>
 
M

Matt Jensen

On further investigation, it is this code

if (Directory.Exists(strDirPathTemp)) {
Directory.Move(strDirPathTemp, strDirPathJobNo);
}

causing the problem, and I note that when this code runs (and the user gets
logged out), the counter for application restarts increases by 1.

I'm reading something that makes me think that maybe some virus checking
software is involved in the problem.

Thoughts?
Cheers
Matt

Matt Jensen said:
Thanks Rahul

Hmm, application restarts are 807 and Requests Queued is 54,000!!!!

And the error occurred for 1 file of 1KB too.

Actually seems to be the code below that's causing the problem, which
renames the file upload directory from a temporary name to the ID number
of the job request (because the webform page in question is for logging a
job, and the directory path ID number is not known until the job is
logged):

//JOB FILES (if they exist)

//Root directory path for JBS job files
string strDirPath = Server.MapPath(".\\" + "/../../detail/files/");
//Response.Write(strDirPath+"<br>");

//New Directory path for logged job files
JBSv4.utils.jbs.v4.utils.utils utilsClass1 = new
JBSv4.utils.jbs.v4.utils.utils();

strLongJobRequestID = utilsClass1.LongJobNumber(intJobRequestID);
string strDirPathJobNo = strDirPath + strLongJobRequestID + "\\";
//Response.Write(strDirPathJobNo+"<br>");

//Directory path used for temporary file storage before JobRequestID
was created
strTempJobRequestID = tbxTempID.Text;
string strDirPathTemp = strDirPath + strTempJobRequestID + "\\";
//Response.Write(strDirPathTemp+"<br>");

//Rename temporary file storage directory (if it exists) to job number
directory
if (Directory.Exists(strDirPathTemp)) {
Directory.Move(strDirPathTemp, strDirPathJobNo);
}

What do I do?

Thanks again for any more help.
Matt


Rahul Soni said:
Hi Matt,

Looks like your appdomain is recycling.

You may check that using Perfmon and application restrats counter to
verify
if your appdomain is recycling.

Also, what is the size of the file which causes the issues? Is it each
and
every file which causes the session to recycle??

--
Thanks,
Rahul Soni

--->The secret to creativity is knowing how to hide your sources<---



Matt Jensen said:
Howdy
I've got a rather strange issue occuring.

I used forms based .NET authentication, although I'm also setting some
session variables when people login.

However, I've found when people use one of my webform pages which
includes a
button that pops up a window where you can upload files, if you upload
files
in this popup window, it seems to somehow clear out all of the session
variables and the users get logged out. However, if people don't upload
files, then their use of the webform page proceeds as required/expected.

I'm planning to phase out the session variables by upgrading my code,
however I can't understand this problem which seems quite strange and
I'd
like to know what the problem is.

Any clues would be greatly appreciated.

Cheers
Matt


If it helps, here is code in question:
The main part of the code behind for the upload page:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack) {
pnlUpload.Visible = true;
pnlUploaded.Visible = false;
}
if (IsPostBack) {
pnlUpload.Visible = false;
pnlUploaded.Visible = true;
}
strJobRequestID = Request.QueryString["JobRequestID"];
btnClose2.Attributes.Add("onclick", "return closeupdate();");


}


public void UploadFile(object Sender,EventArgs E) { //Event handler
for
the upload button
lblFileList.Text = "";

if (Request.Files.Count > 0) { //if there are files attached

//Get directory path
string strDirPath = Server.MapPath(".\\" + "/../../detail/files/" +
strJobRequestID + "/");
//Response.Write(strDirPath);

//if Directory path doesn't exist then create it
if (!Directory.Exists(strDirPath)) {
Directory.CreateDirectory(strDirPath);
}

//Iterate through the Request.Files collection
for(IntLoop=0; IntLoop<Request.Files.Count; IntLoop++) {
if (Request.Files[IntLoop] !=null) { //Checking for valid file
// Since the FileName gives the entire path we use Substring
function
to get the filename (including the file extension).
string StrFileName =
Request.Files[IntLoop].FileName.Substring(Request.Files[IntLoop].FileName.LastIndexOf("\\")
+ 1);
string StrFileType = Request.Files[IntLoop].ContentType;
int IntFileSize = Request.Files[IntLoop].ContentLength;

//Check for file length > 0 and Upload if it is
if (IntFileSize > 0) {
//Save the file to the web server
string filePath = (strDirPath + "/" + StrFileName);
Request.Files[IntLoop].SaveAs(filePath);
lblFileList.Text += "<li>" + StrFileName + "</li>";
}
}
}

}

}



Here is the main code for the webform. Notice the
"multipart/form-data" -
could that be causing the problem somehow?

<form id="JBSv4ServerForm" enctype="multipart/form-data" runat="server">
<div class=JBSv4PopupBody>
<!--begin of body-->
<div class=JBSv4PopupMainBody>
<div class=JBSv4JobListing><asp:panel id=pnlUpload runat="server">
<div class="JBSv4JobListingHeader">
<h3>Attach files to job <%if
(!Request.QueryString["JobRequestID"].StartsWith("Temp"))
{%><%=Request.QueryString["JobRequestID"]%><% } %></h3></div>
<table class="JBSv4JobListingTable">
<tr>
<td><input id="File1" type="file" size="30" name="File1"
runat="server"></td>
<td class="listsTableRight" valign="top" rowspan="5">
<p>Use the 'Browse' buttons to select up to five files, then click
'Upload
files'.</p>
<p>You'll be able to attach more files afterwards if you need
to.</p></td></tr>
<tr>
<td><input id="File2" type="file" size="30" name="File2"
runat="server"></td></tr>
<tr>
<td><input id="File3" type="file" size="30" name="File3"
runat="server"></td></tr>
<tr>
<td><input id="File4" type="file" size="30" name="File4"
runat="server"></td></tr>
<tr>
<td><input id="File5" type="file" size="30" name="File5"
runat="server"></td></tr>
<tr>
<td colspan="2"><input class="formbutton" onclick="closewindow();"
type="button" value="Close window" name="btnCloseWindow">
<asp:button id="CmdUpload" onclick="UploadFile" runat="server"
cssclass="formbutton" text="Upload
files"></asp:button></td></tr></table></asp:panel><asp:panel
id=pnlUploaded runat="server">
<div class="JBSv4JobListingHeader">
<h3>Files attached</h3></div>
<table class="JBSv4JobListingTable">
<tr>
<td>
<p>The following files have been attached:</p>
<ul>
<asp:label id="lblFileList" runat="server"></asp:label></ul>
<p><strong>Please note: </strong>Use the 'Close Window' button
below
when
you are finished which will close this window AND refresh the job
attachments list.</p>
<asp:button id="btnClose2" runat="server" cssclass="formbutton"
text="Close
window"></asp:button>
<asp:button id="btnAttachMore" runat="server" cssclass="formbutton"
text="Attach more
files"></asp:button></td></tr></table></asp:panel></DIV>
<!--end of body--></DIV></DIV></FORM>
 
M

Matt Jensen

This appears to be by 'design'...!!
http://groups.google.co.uk/group/mi...ry+rename+app+restart&rnum=4#71f03aac74f80ba6

Solved using the code on this page:
http://blogs.msdn.com/korbyp/archive/2004/02/19/76411.aspx

Still wondering though what it means that my Requests Queued is 54,000!?

Thanks for any advice
Cheers
Matt



Matt Jensen said:
On further investigation, it is this code

if (Directory.Exists(strDirPathTemp)) {
Directory.Move(strDirPathTemp, strDirPathJobNo);
}

causing the problem, and I note that when this code runs (and the user
gets logged out), the counter for application restarts increases by 1.

I'm reading something that makes me think that maybe some virus checking
software is involved in the problem.

Thoughts?
Cheers
Matt

Matt Jensen said:
Thanks Rahul

Hmm, application restarts are 807 and Requests Queued is 54,000!!!!

And the error occurred for 1 file of 1KB too.

Actually seems to be the code below that's causing the problem, which
renames the file upload directory from a temporary name to the ID number
of the job request (because the webform page in question is for logging a
job, and the directory path ID number is not known until the job is
logged):

//JOB FILES (if they exist)

//Root directory path for JBS job files
string strDirPath = Server.MapPath(".\\" + "/../../detail/files/");
//Response.Write(strDirPath+"<br>");

//New Directory path for logged job files
JBSv4.utils.jbs.v4.utils.utils utilsClass1 = new
JBSv4.utils.jbs.v4.utils.utils();

strLongJobRequestID = utilsClass1.LongJobNumber(intJobRequestID);
string strDirPathJobNo = strDirPath + strLongJobRequestID + "\\";
//Response.Write(strDirPathJobNo+"<br>");

//Directory path used for temporary file storage before JobRequestID
was created
strTempJobRequestID = tbxTempID.Text;
string strDirPathTemp = strDirPath + strTempJobRequestID + "\\";
//Response.Write(strDirPathTemp+"<br>");

//Rename temporary file storage directory (if it exists) to job
number directory
if (Directory.Exists(strDirPathTemp)) {
Directory.Move(strDirPathTemp, strDirPathJobNo);
}

What do I do?

Thanks again for any more help.
Matt


Rahul Soni said:
Hi Matt,

Looks like your appdomain is recycling.

You may check that using Perfmon and application restrats counter to
verify
if your appdomain is recycling.

Also, what is the size of the file which causes the issues? Is it each
and
every file which causes the session to recycle??

--
Thanks,
Rahul Soni

--->The secret to creativity is knowing how to hide your sources<---



:

Howdy
I've got a rather strange issue occuring.

I used forms based .NET authentication, although I'm also setting some
session variables when people login.

However, I've found when people use one of my webform pages which
includes a
button that pops up a window where you can upload files, if you upload
files
in this popup window, it seems to somehow clear out all of the session
variables and the users get logged out. However, if people don't upload
files, then their use of the webform page proceeds as
required/expected.

I'm planning to phase out the session variables by upgrading my code,
however I can't understand this problem which seems quite strange and
I'd
like to know what the problem is.

Any clues would be greatly appreciated.

Cheers
Matt


If it helps, here is code in question:
The main part of the code behind for the upload page:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack) {
pnlUpload.Visible = true;
pnlUploaded.Visible = false;
}
if (IsPostBack) {
pnlUpload.Visible = false;
pnlUploaded.Visible = true;
}
strJobRequestID = Request.QueryString["JobRequestID"];
btnClose2.Attributes.Add("onclick", "return closeupdate();");


}


public void UploadFile(object Sender,EventArgs E) { //Event handler
for
the upload button
lblFileList.Text = "";

if (Request.Files.Count > 0) { //if there are files attached

//Get directory path
string strDirPath = Server.MapPath(".\\" + "/../../detail/files/" +
strJobRequestID + "/");
//Response.Write(strDirPath);

//if Directory path doesn't exist then create it
if (!Directory.Exists(strDirPath)) {
Directory.CreateDirectory(strDirPath);
}

//Iterate through the Request.Files collection
for(IntLoop=0; IntLoop<Request.Files.Count; IntLoop++) {
if (Request.Files[IntLoop] !=null) { //Checking for valid file
// Since the FileName gives the entire path we use Substring
function
to get the filename (including the file extension).
string StrFileName =
Request.Files[IntLoop].FileName.Substring(Request.Files[IntLoop].FileName.LastIndexOf("\\")
+ 1);
string StrFileType = Request.Files[IntLoop].ContentType;
int IntFileSize = Request.Files[IntLoop].ContentLength;

//Check for file length > 0 and Upload if it is
if (IntFileSize > 0) {
//Save the file to the web server
string filePath = (strDirPath + "/" + StrFileName);
Request.Files[IntLoop].SaveAs(filePath);
lblFileList.Text += "<li>" + StrFileName + "</li>";
}
}
}

}

}



Here is the main code for the webform. Notice the
"multipart/form-data" -
could that be causing the problem somehow?

<form id="JBSv4ServerForm" enctype="multipart/form-data"
runat="server">
<div class=JBSv4PopupBody>
<!--begin of body-->
<div class=JBSv4PopupMainBody>
<div class=JBSv4JobListing><asp:panel id=pnlUpload runat="server">
<div class="JBSv4JobListingHeader">
<h3>Attach files to job <%if
(!Request.QueryString["JobRequestID"].StartsWith("Temp"))
{%><%=Request.QueryString["JobRequestID"]%><% } %></h3></div>
<table class="JBSv4JobListingTable">
<tr>
<td><input id="File1" type="file" size="30" name="File1"
runat="server"></td>
<td class="listsTableRight" valign="top" rowspan="5">
<p>Use the 'Browse' buttons to select up to five files, then
click
'Upload
files'.</p>
<p>You'll be able to attach more files afterwards if you need
to.</p></td></tr>
<tr>
<td><input id="File2" type="file" size="30" name="File2"
runat="server"></td></tr>
<tr>
<td><input id="File3" type="file" size="30" name="File3"
runat="server"></td></tr>
<tr>
<td><input id="File4" type="file" size="30" name="File4"
runat="server"></td></tr>
<tr>
<td><input id="File5" type="file" size="30" name="File5"
runat="server"></td></tr>
<tr>
<td colspan="2"><input class="formbutton" onclick="closewindow();"
type="button" value="Close window" name="btnCloseWindow">
<asp:button id="CmdUpload" onclick="UploadFile" runat="server"
cssclass="formbutton" text="Upload
files"></asp:button></td></tr></table></asp:panel><asp:panel
id=pnlUploaded runat="server">
<div class="JBSv4JobListingHeader">
<h3>Files attached</h3></div>
<table class="JBSv4JobListingTable">
<tr>
<td>
<p>The following files have been attached:</p>
<ul>
<asp:label id="lblFileList" runat="server"></asp:label></ul>
<p><strong>Please note: </strong>Use the 'Close Window' button
below
when
you are finished which will close this window AND refresh the job
attachments list.</p>
<asp:button id="btnClose2" runat="server" cssclass="formbutton"
text="Close
window"></asp:button>
<asp:button id="btnAttachMore" runat="server" cssclass="formbutton"
text="Attach more
files"></asp:button></td></tr></table></asp:panel></DIV>
<!--end of body--></DIV></DIV></FORM>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top