c# - Return image content from controller to view MVC3 -
I allow a controller to control the chart and see it directly to see what I did in the razor
& lt; P & gt; & Lt; Img src = "/ test / chart report" /> & Lt; / P & gt; And in the controller I have created an action method such as
Public Action Result Chart Report () {var data = new System.Collections.ArrayList { New {X = date time.NEW AddMonths (-2), Y = 200}, New {X = Date Time.Now Adames (-1), y = 300}, new {x = date time.Now, y = 500}}; New system Web. Helps Chart (400, 200, System.Hellers.Chattheme.blue). Add-Titital ("Price inquiry"). DatabintTable (data, "X"). Type ("PNG"); Return tap; } Now I want to pass the model as it is in the form of parameter for the action of the controller from the scene, so I can create a chart without any DB queries . how can I do this . My visual model is built on
@model MyApp.ViewModels.SampleModel & lt; P & gt; & Lt; Img src = "/ test / chart report" /> & Lt; / P & gt; I tried to
& lt; P & gt; & Lt; IMG src = "/ test / chart report / model @" /> & Lt; / P & gt; and in the controller
public action chart chart (sample model model) // But the model is zero {} < / Div>
You can pass parameters to your controller action as:
& Lt; Img ... src = "/ test / chart report" parameter1 = value1 and parameter2 = value2 "/> and your operation should be as follows: < Controller {public action chart chart (String parameter 1, String parameter 2) {... / The contents of the stream are the client return file (IMGstream, "Image / PNG"). );}}
Comments
Post a Comment