Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9039505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:44:47+00:00 2026-06-16T09:44:47+00:00

All , Say you have a code in a View like this. <img src=’@Url.Action(GetCaptchaImg)’

  • 0

All , Say you have a code in a View like this.

<img src='@Url.Action("GetCaptchaImg")' alt='' />

and of course there is an Action named GetCaptchaImg in the controller which return a FileContentResult to View.

After open this view in FireFox. I found the Html code is

<img alt="" src="/Controllername/GetCaptchaImg" />

the src is not the real physical path . So My question is what is the real physical path of this img, How can I change the image by Ajax call to an Action? Hope you can help me . thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:44:48+00:00Added an answer on June 16, 2026 at 9:44 am

    You can make an ajax call to the actionresult and from that return the name of the image and onsuccess of your ajax call change the image
    Alternatively you can do this thing, which i’ve implemented in my project
    Make your HTML form like this

    @using (Html.BeginForm("ActionResult", "Controller", FormMethod.Post, new { @id = "ImgForm", @enctype = "multipart/form-data", name = "ImgForm", target = "UploadTarget" }))
    {
    }
    

    Make an iframe as target of your form

     <iframe id="UploadTarget" name="UploadTarget" onload="UploadImage_Complete();" style="position: absolute;
            left: -999em; top: -999em;"></iframe>
    

    Your upload control

    Then upload the Image and Show it on your form

     function UploadImage() {       
                $("#ImgForm").submit(); //form id
            }
    
            function UploadImage_Complete() {
                try {
                    //Check to see if this is the first load of the iFrame
                    if (isFirstLoad == true) {
                        isFirstLoad = false;
                        return;
                    }
    
                    //Reset the image form so the file won't get uploaded again
                    document.getElementById("ImgForm").reset();
                    //Grab the content of the textarea we named jsonResult .  This shold be loaded into 
                    //the hidden iFrame.
                    var newImg = $.parseJSON($("#UploadTarget").contents().find("#jsonResult")[0].innerHTML);
    
                    if (newImg.IsValid) {
                        document.getElementById("dp").src = newImg.ImagePath;
                        document.getElementById('profile-pic').src = newImg.ThumbnailPath;
                        document.getElementById("change").style.display = "block";                          
    
                    }
    
                    // If there was an error, display it to the user
                    if (newImg.IsValid == false) {
                        alert(newImg.Message);
                        return;
                    }                      
                }
                catch (e) {
                }
            }
    

    Your Action will look like this

     public WrappedJsonResult ChangeImage(HttpPostedFileBase file)
    {
    }
    

    and your WrappedJsonResult class will look likes

    public class WrappedJsonResult : JsonResult
        {
    
            public override void ExecuteResult(ControllerContext context)
            {
                context.HttpContext.Response.Write("<html><body><textarea id=\"jsonResult\" name=\"jsonResult\">");
                base.ExecuteResult(context);
                context.HttpContext.Response.Write("</textarea></body></html>");
                context.HttpContext.Response.ContentType = "text/html";
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the string Hey . I would like to determine all
Let's say I have this: <div id=wrapper> <pre class=highlight> $(function(){ // hide all links
Let's say I have a class like this : public class MyClass { public
Say I have all these files in a folder: something(34324).php something(34).php something(3433454546).php something(65565).php something(9887).php
Lets say I have a WelcomeActivity. All it does is show you a welcome
Let's say I have a matrix with all 0's with the exception of the
Say I have a query that fetches [type][show_name]. For all [type]==5 records, I need
Let's say you have multiple directories that all exist on the same partition. Let's
All, Lets say I have an assembly compiled under .NET 2.0. Can I run
The questions says it all. Say I have a layout mylayout |-- widgetA `--

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.