Click here to Skip to main content
15,897,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a WebApi that returns data has json and my controller uses ApiController, which is indicated to return data, has it says in this stackoverflow answer.

My situation is that i have to return a View that obtains the data provided by that controller.

- Can i in the same controller return the data and the view or do i have to create another controller?

- After that how can i call the view from a WinForm app?

thk
Posted
Updated 14-Jan-14 6:04am
v2

1 solution

Web API returns JSON data by default and your presentation layer could be web / winforms (not very much recommended)

SQL
- Can i in the same controller return the data and the view or do i have to create another controller?


The same controller can be used for both web & winforms(winforms is not recpmmended)

SQL
- After that how can i call the view from a WinForm app?


My understanding is that you will not call the view from the winforms. views is the presentation layer which renders HTML output for the web. You may needs to call the API's from the winforms rather than calling the view?
 
Share this answer
 
v2
Comments
Lopezd 14-Jan-14 12:14pm    
maybe i've explained wrong. I have a winform that collects data from user (database connection values, name, server, ...) with that, in my webapi, i connect to the user database and use the data to present it in a html file. so my situation is, my api returns the data correctly and i can see it in my html file, but i have to modify my code so it cannot call it using Process.Start(file directory);
That's why i'm asking if i can use the same controller to return the data and return the view (if the view is the only other way i have to present the data) and how can i, when pressing a button(winform), can call it.
thk
Bala Selvanayagam 14-Jan-14 12:19pm    
Lopezd ; are you saying that you have done a windows client (not an HTML web) to pass the connectivity details (database name,userid ...) and then trying to present the data retrieved to the web ? Where does the windows comes and where does the HTML web comes into play ?

sorry, am bit lost here

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900