Inconsistent File Access problem between asp.net and interally invoked console app

C

Chung Ta

I am having a problem opening a text file with read access in a console application to be run as a subprocess, which is invoked by an ASP.NET application. The problem appears to occur on line "f.OpenText()"

FileInfo f = new FileInfo("...")
sr = f.OpenText()
while ((Line=sr.ReadLine()) != null) this.lbFileContent.Items.Add(Line)
sr.Close()
The error message is related to the permission, e.g
Access to the path "\\Server\ShareDir\Filename.dat
This file resides on a network resource

I believe that I have properly set all the permissions required. My ASP.NET application was properly configured with impersonation and integrated windows security setting
If those code lines above are placed in the ASP.Net code directly (i.e. inside somefile.aspx.cs) I have no problem reading the file. However, if these same codes reside in a separate console application, which is invoked by the ASP.NET application (via a subprocess) such as
ConsoleProg = "..."
Params = "..."
ProcessStartInfo pInfo = new ProcessStartInfo(ConsoleProg,this.Params);
pInfo.UseShellExecute = false
pInfo.RedirectStandardOutput = true
Process p = Process.Start(pInfo)
Session["Output"] = p.StandardOutput.ReadToEnd()
p.WaitForExit()

I assume that the subprocess would inherit the access token from the ASP.NET application. But for some reason, the error seems to indicate that this is not the case
Of course, I could rewrite the bulk of the console application and wrap the main logic, deploy it as a library, and use it in ASP.NET directly and in the thin console application. But doing this would take more development time

I would appreciate for any hints, suggestions from everyone
Chun
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top