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 8889763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:20:30+00:00 2026-06-14T22:20:30+00:00

This is my part of View: <img src=@{Html.RenderAction(GetUserProfileImage, Home, new { area = });}

  • 0

This is my part of View:

<img src="@{Html.RenderAction("GetUserProfileImage", "Home", new { area = "" });}" alt="" />

And My Controller:

    public ActionResult GetUserProfileImage() {

        string defaultresult = "http://MyProject.dev/Content/img/sample_user.png";
        if (Member.LogIn()) {

            DBFile file = GetMemberPicFromDB();
            return File(file.Content, file.ContentType);

        } else {
            return Content(defaultresult);
        }
    }

So when I Get File from DB every thing is OK, but when I return URL(by return Content) there is some bad result in rendered html, something like this:

<imghttp: myproject.dev="" content="" img="" sample_user.png="" src="" alt="">

    <div>
        some content from outside of img tag added here
    </div>
</imghttp:>

Also I change the View to:

<img src="http://myproject.dev/Content/img/sample_user.png" alt="" />

And every thing is OK,

So where is the problem? it seems return Content can not return simple string to src attribute, So what is your suggestion for return simple string?

if that not possible

I think to get File by URL(http://myproject.dev/Content/img/sample_user.png) and return File() Like when returned from DB, but how can I get the file in controller by this URl(http://myproject.dev/Content/img/sample_user.png) ?

and any other suggestion if you have?

  • 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-14T22:20:32+00:00Added an answer on June 14, 2026 at 10:20 pm

    You should return a file from your controller action in both cases and reference this action in your image, like this:

    <img src="@Url.Action("GetUserProfileImage", "Home", new { area = "" })" alt="" />
    

    and then in your controller action return a File result in both cases:

    public ActionResult GetUserProfileImage() 
    {
        if (Member.LogIn()) 
        {
            DBFile file = GetMemberPicFromDB();
            return File(file.Content, file.ContentType);
        }
        else 
        {
            string image = Server.MapPath("~/content/img/sample_user.png");
            return File(image, "image/png");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is part of my spark partial view (it is called TaskSearch): ${ Html.DropDownList(Search.Status,
Booking.java This is part of my spinner code. public void onItemSelected(AdapterView<?> arg0, View v,int
Please, take a look at my code bellow. This part pops top view controller
Considering this part of a Java class, private List<Object> components = new ArrayList<Object>(); private
This part of my code works fine: #include <stdio.h> int main(){ //char somestring[3] =
This part of my code is used to award a grade to a student
This part of an app that I am working on, I have the following
I have this part of script from my GAE application which uses webapp2, which
I want to code this part of a VB6 application in c#. How can
I added this part of the code in my onCreate() method and it crashes

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.