Why has an ASP.NET MVC project a WebApiConfig.cs - asp.net-mvc

When I create a MVC4 project and choose basic mvc project
I find WebApi related code why this?

Because Microsoft hope that you will use Web API 8-)
http://www.asp.net/web-api
If you don't want to, you can ignore it or even comment it in Global.asax
// WebApiConfig.Register(GlobalConfiguration.Configuration);

Related

add an ASP.NET MVC project to an existing ASP.NET Web forms application

How to add an ASP.NET MVC project to an existing ASP.NET Web forms application. How to call MVC project page from existing website.
You can refer this step-by-step guide on how to do that.
Your question is similar to
Is it possible to host an asp.net MVC in the same folder as asp.net web forms app?
We were in the exact same situation as you and it's not as bad as you might think. Thanks to Nuget it's a fairly easy process that you can follow and Dave Paquette describes how to do it in his blog post
And once you've got Mvc up and running all you need to do to go from one to the other is to redirect to Mvc from webforms:
Response.Redirect("~/Controller/Action/")
You can also use the Mvc routing system to generate routes from within webforms as well:
System.Web.Mvc.UrlHelper url = new System.Web.Mvc.UrlHelper(HttpContexxt.Current.Request.requestContext)
Response.Redirect(url.Action("Action", "Controller"))

Join MVC part to existing ServiceStack project

everyone. I've got ServiceStack project and I want to add mvc part(some controllers and views) to it.
I tried just installed MVC and add an area, but it doesn't work.
I tried create new MVC project in the solution, but they work separately.(but I have no ideas how to merge their routes)
Any suggestions?
To use ServiceStack with ASP.NET MVC you need to configure ServiceStack to be hosted on a custom route e.g. /api this way ServiceStack doesn't conflict with ASP.NET MVC Razor handling and you can have ServiceStack handle all Service Routes from /api.
Configure ASP.NET MVC with ServiceStack
Access ServiceStack from MVC
Otherwise you can just use ServiceStack's Razor Support, in which case it can't be used with ASP.NET MVC (as it conflicts and tries to hijack Razor views), so to use ServiceStack Razor start with an empty ASP.NET Project and add the NuGet package:
PM> Install-Package ServiceStack.Razor
and register the RazorFormat plugin, e.g:
Plugins.Add(new RazorFormat());
You can find info about ServiceStack.Razor on razor.servicestack.net

Difference between WebApiConfig.cs and RouteConfig.cs

What is the difference between WebApiConfig.cs and RouteConfig.cs in the App_Start folder of an MVC Web API project in Visual Studio 2012?
The following are the key differences:
RouteConfig.cs is exclusively for configuring ASP.NET routes.
WebApiConfig.cs is for any Web API related configuration, including Web-API-specific routes, Web API services, and other Web API settings.
As cmotley mentions, the ASP.NET web site includes a good listing of what types of configuration can be done in WebApiConfig.cs in this article.
There is no difference as they both accomplish the same thing - adding routes to your route collection. You don't need to use the WebApiConfig class; it's simply a convenient way to organize your code.
If you are familiar with ASP.NET MVC, Web API routing is very similar to MVC routing. The main difference is that Web API uses the HTTP method, not the URI path, to select the action. You can also use MVC-style routing in Web API. This article does not assume any knowledge of ASP.NET MVC.
From Routing in ASP.NET Web API

Adding MVC3 to existing webforms solution

OK so I have a large .NET 4.0 webforms solution with many projects. I want to develop a new set of screens in MVC3 that integrate into the site. Do I need to change the webconfig and routing in the existing webforms (web application) root? That seems risky. Can I just add an MVC3 project and integrate that into the web application? What's the easiest, least risky way? Does all the routing have to be done at the root? Also, we use NCache for state management. Thanks.
There is nothing about the "solution" that is webforms, so yes, you can add an MVC project to the solution. If you want to add MVC3 components to an existing webforms project, you can do that, too, but you will have to do some of the work the MVC3 project wizard does for you, like adding routes in global.asax.cs and making some web.config changes. Once complete, a hybrid webforms/MVC3 application works fine.
My recommendation, if you want to go this route, is to create an MVC application and look at the things that it puts into the Global.asax.cs file and the web.config file and compare that to your current application.
Check out
http://www.hanselman.com/blog/IntegratingASPNETMVC3IntoExistingUpgradedASPNET4WebFormsApplications.aspx for a good primer.

Can i add MVC project in normal asp.net c# project?

can anybody tell me that if i made a normal asp.net c# project and in that solution i want to add mvc project. so is it possible to call mvc view from normal page which is in first project? if yes then how can i call view page from normal page of asp.net c# project.
on live server how can i call mvc page?
Thanks
Samir
Mixing VB ASP.NET and C# ASP.MVC projects in a single solution
Ok, couple of different things here.
Can a ASP.NET forms project exist in the same solution? Yes
Can you mix MVC with WebForms in the same project? No
Can a MVC site communicate with a WebForms site? Yes, you can easily pass between via simulated form submission or by URL. You could also configure cookies to work across both sites.
Can you have an MVC site and a WebForms site use the same url? No

Resources