Click here to Skip to main content
15,919,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to add cshtml view in web api? From cshtml file i need to open one kendo window and fill the details and those details are save into database without any refresh the page it is automatically reflect in kendo grid?

What I have tried:

I created separate html file and i did. But i want it in cshtml file.
Posted
Updated 7-Oct-16 2:31am
Comments
Afzaal Ahmad Zeeshan 7-Oct-16 9:08am    
Web API doesn't have this HTML garbage. Web API returns the data in either XML or JSON format.

The simple answer is that you don't. .cshtml is the purview of MVC.NET, not WebAPI. The WebAPI framework is not setup to render dynamic pages on the back end as part of the design philosophy: it is intended for use with a JavaScript ajax parser that handles client-rendering or simply as a data source.

If you want to change the architecture to render pages from the server, you'll need to do one of two things: add a cshtml renderer (such as RazorEngine) to your project and manually send that down the pipe, or mix an MVC.NET controller in to handle the views.
 
Share this answer
 
You don't.

WebAPI's don't put up any kind of user interface at all. It is strictly methods performing actions on a data model and/or returning data. That's it. Nothing more.

It has no facility at all for returning a UI renderable page.

Now, if you're talking about "but I've seen HTML pages no WebAPI's!". No, you haven't. You've seen web pages/sites that accept data and call WebAPI methods for you and relay the returned data back to the browser. You did NOT call the WebAPI method directly.
 
Share this answer
 

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