Please, Please help me

G

Guest

Hello,
I am in serious need of help. I have an ASP.NET application written in C#.
I have a page that processes a file on the web server. The page uses a class
I created and stored in the AppCode directory. In the class method I am
trying to run a program on my web server that will convert the file for me.
Here is a snipit of code:

System.Diagnostics.Process proc = new System.Diagnostics.Process();

proc.StartInfo.FileName = sDir + "App_LocalResources\\FileConverter.exe";
proc.StartInfo.Arguments = "-i " + filename + "." + extension;

proc.EnableRaisingEvents = false;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;


proc.Start();
proc.WaitForExit(99999999);

if (!proc.HasExited)
proc.Kill();
proc.Close();


The problem is that as soon as my code gets to proc.Start I get an 'Access
is Denied' error. I have tried everything I could think of or find on the
web. Could someone please help me out with this?

Thank you,
Michael
 
A

Aidy

Remember that if you use anonymous authentication that the process is
running as the aspnet account which is local to the machine and has
restricted permissions. Ensure your anonymous user has the rights to do
whatever this EXE is trying to do. Also make sure it doesn't instigate any
pop-ups, message boxes etc.
 
G

Guest

Sorry Aidy,
but that does not really help. I have given permissions to all the
accounts I can think of on the app_localresources folder and the exe's as
well.
I really need someone to explain to me from beginning to end how to set this
up.

Thanks,
Michael
 
G

Guest

Try this:

In the folder the FileConverter.exe resides:
- Give "Everyone" read/write/execute access (make sure to change any other
user accounts you already have set up for that folder)

Try running it - if it works, you had a permissions issue for that folder,
but I would recommend taking out the "Everyone" account as soon as possible
and figuring out the correct ASPNET or IUSER_[MACHINE_NAME] account(s) that
need permission.

If it doesn't work, do the same for whatever folders this particular
application is accessing - it sounds like you're manipulating files, so
wherever any file reading/writing is being done, give "Everyone" read/write
access to those as well.

If this works, you had a permissions problem with that folder. If not, I'm
sorry that's all I can think of right now.

If that doesn't help you and you have control over the source for this
FileConverter.exe, figure out a way to pull the applicable routines into a
sharable class that you can use in both the FileConverter.exe and your web
app. Again you're going to need read/write permissions to the folder you're
manipulating files in, but at least it takes out the possibility that there's
a problem executing the windows app.
 
K

Kevin Spencer

Hi Michael,

A Security Exception can be thrown if the code that is running is not
granted the necessary Code Access security. This may refer to your web
application (which I doubt, as ASP.Net web applications are granted Full
Trust by default) or the executable that your web application is trying to
start (more likely). Check out the following articles on Code Access
Security:

Improving Web Application Security: Threats and Countermeasures
http://msdn2.microsoft.com/en-us/library/ms994921.aspx

Code Access Security in Practice
http://msdn2.microsoft.com/en-us/library/aa302424.aspx

How To: Use Code Access Security in ASP.NET 2.0
http://msdn2.microsoft.com/en-us/library/ms998326.aspx

Using Code Access Security with ASP.NET
http://msdn2.microsoft.com/en-us/library/aa302425.aspx

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
G

Guest

Kevin,
thank you so much for your help. All of that information was great, but I
could not find anything that addressed accessing an third party exe. I have
tried everthing you suggested and have not got it to work yet. It works find
while I run it locally using VS. Just not on my production server.

Michael
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top