Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
Following is my code and not working on iis. But working on local.
This code is to convert up file to wav file and play after.
 
It convert and store audio file on local but not on IIS
 

 public void ExecuteCommandSync(object command)
    {
        try
        {
            string exepath;
            string AppPath = Request.PhysicalApplicationPath.Replace("http:\\", "");
            ////Get the application path
            //exepath = Server.MapPath("Up2Wav.exe");
            exepath = Server.MapPath("tmp/Up2Wav.exe");
            string strCmd = exepath + " " + command;
            StreamWriter _testData = new StreamWriter(Server.MapPath("data.txt"), true);
            _testData.WriteLine(strCmd);
 

            System.Diagnostics.ProcessStartInfo procStartInfo =
                new System.Diagnostics.ProcessStartInfo("cmd", "/c " + strCmd);
            // The following commands are needed to redirect the standard output.
            // This means that it will be redirected to the Process.StandardOutput StreamReader.
            procStartInfo.RedirectStandardOutput = true;
            procStartInfo.UseShellExecute = false;
            // Do not create the black window.
            procStartInfo.CreateNoWindow = true;
            // Now we create a process, assign its ProcessStartInfo and start it
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo = procStartInfo;
            proc.Start();
            // Get the output into a string
            string result = proc.StandardOutput.ReadToEnd();
            // Display the command output.
            Console.WriteLine(result);
            _testData.WriteLine(result);
            _testData.Close();
            _testData.Dispose();
       
        }
        catch (Exception objException)
        {
            // Log the exception
        }
    }
Posted 5-Oct-12 2:24am
Edited 5-Oct-12 3:09am
v2
Comments
Jonathan [Darka] at 5-Oct-12 8:30am
   
Do you know which line it's failing on?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

System.Diagnostics.Process.Start is working fine.
 
But it always runs on the Server, not the Client - that is where the code in the code behind is executed.
 
So when you say Process.Start, the application runs just as it used to - on the server. When you were developing, the server and client were the same machine, so it seemed to exactly what you wanted.
 
You cannot run any application on the client from the server: security forbids it.
  Permalink  
Comments
ravi sharma11 at 6-Oct-12 0:20am
   
My up audio file is on server and my converter u p2wav.exe is also on server. How can I have to pass mu source and destination file in up2wav.exe on server how to do it.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Like a lot of people here, you seem to have serious confusion about ASP.net and the client-server architecture. Your C# code runs on the web server – not on the client. Its job is to create markup or other resources (e.g. images, scripts etc) which are sent to the browser. All that happens on the client side (i.e. the machine with the browser) is that the markup or resources are rendered, and JavaScript code is run.
 
You cannot make a C# function which will run on the client machine. Anything which you do in the code behind will only ever happen on the server. Spawning processes very rarely makes sense on the server, and in fact most professional hosting environments won't give permission to the ASP.net engine to do so.
 
This confusion is understandable considering that Microsoft wrote ASP.net in a way which deliberately blurs the boundary between client and server, i.e. controls that are rendered on the client 'exist' on the server, and setting properties in code behind results in (after a page refresh or AJAX call) values changing on the client, or vice versa. But it is still a standard web server and browser client architecture underneath, and it's important to understand that.
 
In this case, if the WAV converter doesn't have an embeddable public API, you still actually do need to spawn a process to run it. However, you need to respond to the client when the process finishes and give a URL that the client can use to retrieve the WAV file.
  Permalink  
Comments
ravi sharma11 at 6-Oct-12 0:19am
   
My up audio file is on server and my converter u p2wav.exe is also on server. How can I have to pass mu source and destination file in up2wav.exe on server how to do it.
BobJanova at 9-Oct-12 4:48am
   
um, read the last sentence of my answer ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 495
1 OriginalGriff 339
2 ChintanShukla 305
3 Richard Deeming 260
4 RyanDev 230
0 Sergey Alexandrovich Kryukov 8,858
1 OriginalGriff 7,451
2 CPallini 2,603
3 Richard MacCutchan 2,095
4 Abhinav S 1,893


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100