473,387 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Session variables disappear in relation to a file upload

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>
Dec 7 '05 #1
4 4440
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" wrote:
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>

Dec 7 '05 #2
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" <Ra*******@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...
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" wrote:
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>

Dec 7 '05 #3
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" <re***************@microsoft.com> wrote in message
news:uB***************@TK2MSFTNGP12.phx.gbl...
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" <Ra*******@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...
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" wrote:
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>


Dec 7 '05 #4
This appears to be by 'design'...!!
http://groups.google.co.uk/group/mic...f03aac74f80ba6

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

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

Thanks for any advice
Cheers
Matt

"Matt Jensen" <re***************@microsoft.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...
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" <re***************@microsoft.com> wrote in message
news:uB***************@TK2MSFTNGP12.phx.gbl...
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" <Ra*******@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...
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" wrote:

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>



Dec 7 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ruben van Engelenburg | last post by:
Hi all, I have a strange problem. I have a login procedure that uses a mysql database in which the users are stored. The login procedure is pretty straightforward. In every page I unclude my...
9
by: Pack Fan | last post by:
I've noticed that session variables will persist on Mac IE even after all browser windows have been closed. One must quit the program to clear the session variables. This presents a security risk...
9
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
1
by: Wiktor Zychla | last post by:
Hello there, I've just encountered a strange problem with Session. In one particular scenario it is cleared between pages but the scenario is so specific that I am really, really startled. I've...
13
by: Alexander Widera | last post by:
hi, who has seen the follow problem or could help please? i visit a page .... i read a sesssion-var . ... everythink works...... i visit the page again..... error ... the sessionvar is null .... i...
4
by: osh.sean | last post by:
I'm having a problem and I can't find anything about this anywhere else out there. I'm working on a solution that allows the end user to create folders / upload files to the web server. Some...
5
by: Simon | last post by:
Hi all, We have a small problem. We are running an ASP.NET1.1 application, using IIS6 on server2003, no web farm, on a single server, using in-proc session state, only using one worker...
7
by: mantrid | last post by:
I have some code to upload files to my site. it works when the <input type="file" is posted once even when I use session variables from the posted variables but when I carry those session variables...
11
by: Dave | last post by:
I have a site with an App_Code folder that has Global.asax.cs and a file named Upload.cs. I want to pass Upload.cs a Session variable (username) that is set in default.aspx. Setting up a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.