0

I've a java script function that is used to save a webcam Image and the code is as below.

onCapture: function () {
                webcam.save("@Url.Content("~/Image/ImageCapture")/");
                MatchFindFunction();
            }

and in my controller the code is as below.

public void ImageCapture() //Capturing the image and save to folder
        {

            if (!Directory.Exists(Server.MapPath(@"~/Temp")))
            {
                Directory.CreateDirectory(Server.MapPath(@"~/Temp"));
            }

            string sessionIdValue = getSessionID();
            tempPath = "~/Temp/" + sessionIdValue + ".jpg";
            System.Web.HttpContext.Current.Session["tempImagePath"] = sessionIdValue;

            CommonModel.path = Server.MapPath(tempPath);
            CommonModel.stream = Request.InputStream;
            using (CommonModel.reader = new StreamReader(CommonModel.stream))
                CommonModel.dump = CommonModel.reader.ReadToEnd();
            System.IO.File.WriteAllBytes(CommonModel.path, ConvertStringToByte(CommonModel.dump));
return sessionIdValue;
        }

So Here my requirements is, I want to get this returned value in Javascript, I have to pass this variable to another function. I tried doing alert(webcam.save("@Url.Content("~/Image/ImageCapture")/")), but the message alerted here is true, but I want the sessionIdValue in return. I'm confused, if I have to use Ajax, if so, I'm not sure of how to call this URL. As this is webcam save method.

Please let me know on how can I do this.

Thanks

1 Answer 1

1

This @Url.Content("~/Image/ImageCapture") is your return value. just use this instead of using webcam.save("@Url.Content("~/Image/ImageCapture")/" in alert function.

Sign up to request clarification or add additional context in comments.

12 Comments

and if you can't access this value as an image or string, then must check the action.
Hi @Eisa, Thanks for the quick response, Unfortunately, the response that I get is /Image/ImageCapture. :( please let me know where am I going wrong...
first of all check what is response value when you call this action. type [local host or IP]/Image/ImageCapture in address bar..
If response is an image, then use $([selector of an image]).attr('src', '@Url.Content("~/Image/ImageCapture")'); to show it in an image tag.
Try alert("[local host or IP]/Image/ImageCapture");
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.