server application aspnet_wp.exe stopped unexpectedly unavailable

P

phancey

hi,

I'm having an absolute nightmare with this!

I've seen many posts on the subject but still can't quite figure it
out.

I'm using csharp and Framework 1.1.4322.537 on Windows2000 Professional
5.00.2195 Service Pack 4

I click a hyperlink which takes me to an aspx page with a document ID
in the request string. The aspx page checks if there is a doc_id in the
request string. If there is, it looks at a Session variable DataView to
find the location of the document based on the doc_id (don't want users
to see actual location).

Once it has this info, it puts that into another Session Variable and
does a Response.Redirect to the same aspx page but with a user-friendly
request string i.e document=documentType.documentName

On reentry, the page sees this request string, finds the location from
the session variable and uses the following code to serve the PDF file:
if(impersonateValidUser("user", "domain", "password"))
{
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType="application/pdf";
Response.WriteFile(pdfFile);
Response.Flush();
Response.Close();
undoImpersonation();
}
else
{
}
return;

using the standard MS implementation of impersonation found here:
http://support.microsoft.com/default.aspx?scid=kb;en-us;306158
EXCEPT that I am not doing it in Page_Load.

Code for Page_Load is:
//uses doc_id to identify which document from the dataset is required.
string objectName;
string objectType;
if (Request.QueryString["doc_id"] != null)
{
string docId = Request.QueryString["doc_id"];
System.Data.DataView documents =
(System.Data.DataView)Session["documents"];

if (documents == null)
throw new Exception("You must navigate via the Document Viewer and
select a document first.");
documents.RowFilter="doc_id="+ docId;
//check that there is a document
if (documents.Count==1)
{
objectName = documents[0].Row["object_name"].ToString();
objectType = documents[0].Row["r_object_type"].ToString();
pdfFile = (string)Session["pdfLocation"] +
documents[0].Row["DOCUrl"].ToString();
ArrayList pdfArray = new ArrayList();
pdfArray.Add(pdfFile);
pdfArray.Add(docId);
pdfArray.Add(objectName);
pdfArray.Add(objectType);
Session["pdfArray"] = pdfArray;
string newURL = HttpContext.Current.Request.Path + "?object=" +
objectType + "." + objectName;
Response.Redirect(newURL);
return;
}
else
{
throw new Exception("There is no such document id in the
current dataset.");
}
}
else
{
if (Session["pdfArray"] != null && Request.QueryString["object"] !=
null)
{
if (((ArrayList)Session["pdfArray"]).Count == 4)
{
pdfFile = (string)((ArrayList)Session["pdfArray"])[0];
objectName = (string)((ArrayList)Session["pdfArray"])[2];
objectType = (string)((ArrayList)Session["pdfArray"])[3];
string[] objRequest =
Request.QueryString["object"].Split(".".ToCharArray());
if (objRequest.Length == 2)
{
if (objRequest[0] != objectType || objRequest[1] != objectName)
throw new Exception("This is not a valid document.");
}
else
throw new Exception("This is not a valid document.");
ServePDF();
return;
}
else
{
throw new Exception("This is not a valid document.");
}
}
else
{
throw new Exception("This is not a valid document.");
}
}

string pdfFile is a class variable.

Now, this code works fine for 3 of my documents which are under 200kb
but the one that is 3822KB fails with the error message Server
Application Unavailable and the event log says aspnet_wp.exe stopped
unexpectedly.

The machine.config is set to use SYSTEM (though with Framework 1.1 I
don't think this should be necessary, and indeed it may not be - have
now tested "machine" and that seems to work the same). The httpRuntime
MaxRequestLength in machine.config was 4096 and since this was close I
upped it to 8192 but that didn't fix it. This setting is not overridden
in the web.config file.

What may give the game away (but not to me!) is that the Page_Load is
triggerred 3 times instead of the 2 I was expecting. Once with the
doc_id, then after the Redirect but then a third time??? Presumably
something to do with the Response.Flush or Response.Close...

Can anyone help me? Even more frustrating is that I actually had this
big file working occasionally yesterday though it would randomly cause
this error message. However, after my tinkering it always produces the
error now :eek:( (only for the large file).

thanks
Phil
 
P

phancey

i should say I have also tried without impersonation (having set the
directory permissions appropriately, though my final application will
need to use impersonation or delegation - that's a whole different
question!).

Even without impersonation I still get the same problem.

Phil
 
P

phancey

can someone at least tell me why Page_Load is being triggerred 3 times
in this example?

I really can't figure out why the failure is so random...
 
A

aschmidt

can someone at least tell me why Page_Load is being triggerred 3 times
in this example?

I really can't figure out why the failure is so random...


That's a bug. Install .net framework 1.1 sp1. this would help.
 
P

phancey

by the way, for anyone else having this problem, it turned out to be
the size of the file at 3822KB. I ended up having to read it in chunks
and outputting it with flush before reading the next chunk. I used
500000 byte chunks and it seems to work fine. There may be an
alternative solution but this is what I ended up doing.
 

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,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top