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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:53:21+00:00 2026-05-26T14:53:21+00:00

I’m using ASP.Net with MVC 3 and trying to auto generate images. In my

  • 0

I’m using ASP.Net with MVC 3 and trying to auto generate images. In my view I am probably going to generate anything from 1 to a 50 images (maybe more eventually) which are currently one shot throw away images. This is because they show the current results of my data, which gets updated fairly frequently and so the generated images can’t be relied on for very long.

Currently I am graphing results on the fly. Users can select which results to view and how then I get the results, write the graphs to file then pick up the filenames and display them in my view, but this is not working out so well and as I do not re-use the images I would just prefer to not bother storing them at all.

So far my solution is based on the following idea Can an ASP.NET MVC controller return an Image?.

In my controller I have:

public ActionResult GetImage(GraphData GraphData)
    {
        Response.ContentType = "image/png";
        using (var ms = new MemoryStream())
        {
            var chart = GraphService.GetChart(GraphData.ResponseItems,GraphData.QuestionDisplaySetup,GraphData.QuestionCutOffs,250,250);
            chart.SaveImage(ms, ChartImageFormat.Png);
            ms.Seek(0, SeekOrigin.Begin);

            return File(ms.ToArray(), "image/png");
        }

    }

and then in the .cshtml file:

foreach (var item in @Model.GraphDataList)
{
    <img src="@Url.Action("GetImage", "Download", new { GraphData = item})" alt="" /> 
}

and a model:

public class GraphData
{        
    public IEnumerable<ResultItem> ResultItems { get; set; }
    public ResultDisplaySetup ResultDisplaySetup { get; set; }
    public IEnumerable<ResultCutOff> ResultCutOffs { get; set; }
}

but as you probably have guessed by the question this does not work.

If I do the following in my .cshtml/view:

Html.RenderAction("GetImage", "Download", new { GraphData = filename });

Then I pickup the object in my controller action without any problems, however I can’t use that in the img tag and ASP.NET MVC null model passed to controller action tells me @Url.Action can’t send a complex objects.

I fell down a rabbit whole of trying to generate the serialized objects myself and write my own url builder using RouteValueDictionary and tagbuilder, which is probably possible. An example is:
Passing an object to HTML attributes

but this example is just too simple and obviously so I am as I couldn’t quite get the thing working.

I have the added complication that likely the Html.RenderAction will not work on the published website because it is not at the root of the website (e.g. /whatever/MyWebSite) this is for security purposes and would be too difficult to change right now.

Anyway it seems like I am working against the framework instead of with it. Any ideas anyone?

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-05-26T14:53:22+00:00Added an answer on May 26, 2026 at 2:53 pm

    It is not a good idea to pass complex objects in a URL.

    Instead, store them in the session, pass an identifier for the object in the session in the URL, and read it from the session in the action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a view passing on information from a database: def serve_article(request, id): served_article
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.