Voice recording on ASP.NET RRS feed

  • Question

  • I am using winmm.dll to record audio from user and save it in to directory. Every thing was work fine but after publishing using URL it says, the audio file was not found. Path is correct but the audio is not saving.

    [DllImport("winmm.dll", EntryPoint = "mciSendStringA", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
            private static extern int record(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);

    protected void btnStopRecording_Click(object sender, EventArgs e)
                    lblRecording.Visible = false;
                    string userId = Request.QueryString["id"];
                    timer.Enabled = false;
                    string path = Server.MapPath(@"~/Recordings/'" + userId + "'(1).wav");
                    path = path.First().ToString().ToLower() + path.Substring(1);
                    record("save recsound " + path, "", 0, 0); 
                    record("close recsound", "", 0, 0);
                    btnStartRec.Enabled = false;
                    btnStopRecording.Enabled = false;
                    btnSave.Enabled = true;
                catch (Exception)


     Can anyone help me with the issue.

    Server Error in '/' Application.

    Could not find file 'c:\inetpub\wwwroot\VoiceAuthentication\Recordings\'usr_a0529bb472f54d85bb0feb1908f46e51'(1).wav'.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.IO.FileNotFoundException: Could not find file 'c:\inetpub\wwwroot\VoiceAuthentication\Recordings\'usr_a0529bb472f54d85bb0feb1908f46e51'(1).wav'.

    Source Error: 
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace: 
    [FileNotFoundException: Could not find file 'c:\inetpub\wwwroot\VoiceAuthentication\Recordings\'usr_a0529bb472f54d85bb0feb1908f46e51'(1).wav'.]
       System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +1344
       System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1217
       System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +144
       System.IO.File.InternalReadAllBytes(String path, Boolean checkHost) +122
       VoiceAuthantication.VoiceRecord.RecordingWebForm.btnSave_Click(Object sender, EventArgs e) in D:\VoiceAuthantication\VoiceAuthantication\VoiceRecord\RecordingWebForm.aspx.cs:175
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +11758656
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +150
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5028

    • Moved by CoolDadTx Friday, April 12, 2019 1:55 PM ASP.NET related
    Friday, April 12, 2019 4:01 AM

All replies

  • Hi

    Thank you for posting here.

    Since this thread is related to asp.net, you could post in the following forum.


    The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, April 12, 2019 5:34 AM
  • Since the recoding is done on ASP server, but the form is displayed in browser on different computers, it is not clear how it will record the sounds.

    See also: https://forums.asp.net/t/2144081.aspx etc.

    Friday, April 12, 2019 5:34 AM