Webapi with MVP based webform application - webforms

We have a web application built using ASP .NET 4.5 Webforms stack and based on MVP Pattern.
We are currently in the process of making certain aspects of the application service-oriented
which can then be used to serve the relevant content to third party clients.
Rather than doing a major overhaul, one of the options we are looking out is exposing this as WebAPI endpoints. Is anyone aware of codeplex/github hosted sample projects demonstrating the use of WebAPI ends points with MVP based webforms application? Any suggestions/insight/ recommendations would be helpful? Thanks.

A sample using Web Forms + Web API can be found here:
http://aspnet.codeplex.com/sourcecontrol/latest#Samples/WebApi/WebFormSample/ReadMe.txt

Related

Service Layer with WebApi

I am starting to work on a new project so working on laying on the architechture at this moment.
So basically we want to keep a service oriented architecture using MVC web api.
So I had the following structure in mind:
Project.Core (All Poco classes)
Proect.Data (All entity framerwork)
Project.Service (All Web API ??)
Project.Web
We would be working for the first time on webapi here. So wanted to know how do we intergrate webapi here.
Most of the articles we saw read had created a mvc web application and had selected webapi in that. But we
were looking to create separate service layer just for webapi. Is this the correct practice to do that or
I am missing something here.
We basically wanted not to have a tight coupling b.w MVC web and web api here. If we create web api as part
of mvc then how can we separately access our web api.
WOuld appreciate inputs.
I normally use the project template provided by Visual Studio. Choose Empty ASP.NET project template and then select Add folders and references for Web API. It will create the folder structure needed/recommended purely for a Web API project without any MVC reference. I generally create a separate project for Data Access and use that from the Web API project.

ASP.Net Core MVC/WebApi - talking to each other over HTTP?

I have a theoretical (and probably foolish) question about web api and an mvc webapp in .Net Core.Seeing as they overlap in Core, it's even easier to have an api and visual app in the same project, responding to different routes - great!
But, there's something architecturally fundamental which I always struggle with : Let's say I had a web api, which other services use to do some data things and some custom actions etc. Then, I also have a big mvc app, this is the central app (let's say for argument).. Here's the question.
1) Should the mvc app be making webapi calls over http(even though they will likely run on the same box - they dont have to of course), 2) Should the mvc app be sharing the service and repository classes with the webapi?3) Should the mvc app be programatically calling webapi from mvc?(i.e. injecting the webapi classes into mvc controllers - therefore having a dependency on deployment, but abstracting the api logic and avoiding http)
Please don't let me know if this is stupid question...

WCF or Asp.Net MVC for API acess?

I wanted to get some thoughts about API access either through WCF or MVC. Either works, but I like the idea of using MVC to build custom routes. I know this is possible with WCF (maintaining the request routes), but aside form the security disadvantages of not using WCF (which are not deal breakers) what other thoughts does the community have regarding this.
I have a project where we have been discussion using MVC or WCF and we are comfortable with both, but we are swaying towards MVC.
You should use the new ASP.Net MVC Web API framework, new to MVC 4.0.
I think MVC makes a great web API. I did this not too long ago for an android app that uses a RESTful web API using MVC 3. Here's a good tutorial:
http://msdn.microsoft.com/en-us/magazine/dd943053.aspx
If you're feeling adventurous check out the Web API framework included in MVC 4. NOTE: I have not experimented with this yet but plan to in the near future. See here: http://www.asp.net/web-api

Migrating a legacy Webforms application to asp.net mvc?

does anyone have good links or tips on best practices concerning migrating from ASP.NET Webforms to ASP.NET MVC?
We have a large webforms application that we would like to piece by piece migrate to MVC. Here is our current setup.
Two big Webforms project (VB)
Multiple class libraries and services (C# and VB.Net)
Subsonic 2.2 Data access layer
SQL Server 2008 DB
We are considering the following:
Keep the classic webforms project running as is for now while developing.
Create new MVC project based on MVC 3 with Razor view engine
Use Nhibernate (Repository pattern) DAL
Convert/build the existing functionality module by module in the MVC project
Replace some functionality in the old webforms project with new MVC modules if possible. Integrate via eg. Iframes.
In time the new MVC app will replace the old webforms project entirely.
We would like to keep the DB as is so we also need a tool to create the Model based on the DB.
Is this a possible solution?
WebForms applications use server-side session a lot because most of the server controls use it internally. You will not be able to use any of the server controls that you used in WebForms in MVC3 (atleast without some tinkering).
MVC3 promotes the use of restful architecture, where any state is maintained in html or url or cookies, and these are reasons why I think you should revisit the decision to convert to MVC3. Do so only if it will give you a huge advantage, because I suspect you will be reinventing ground up your existing app - I suspect there will be an equal amount of effort migrating it as to while developing it new.
Again there is nothing preventing you from creating an "area" or a "region" of MVC in your webforms app, if your goal is to use MVC for future development.
If you still want to move to MVC3, take a look here
It is ok solution. Also for NHibernate you can use MyGeneration with NH plugin to generate models on top of existing DB. And it is also possible to host WebForms and MVC together in one web app. Just finished quite the same task. But used EF for DAL.

.NET 4.0 MEF. Pluggable ASP.NET MVC 3.0 Approach

I am going to start new MVC 3.0 .NET 4.0 application.
I want to implement each component for my web site once and simply reuse it then for another web sites i going to build.
Currently i am looking the best practice i can use to achieve my goal.
I did some research and found that I may get a lot of advantages using MEF.
I found interesting MEF MVC solution called plugable MVC http://www.thegecko.org/index.php/2010/06/pluggable-mvc-2-0-using-mef-and-strongly-typed-views.
Is it really worth to use such kind of approach(Plugabble MVC) of building MVC apps?
Advantages disadvantages of pluggable MVC?
May be somebody may suggest something else?
What specific problem are you trying to solve? MVC is a very extensible and pluggable framework as it is. I would say that for a simple site MEF is not necessary. Please provide more information on the issues you are running into with the stock MVC framework.

Resources