You are on page 1of 3

mvc and webforms Assemblies para referenciar: System.Web.Mvc System.Web.Routing System.Web.Abstractions web.config: <configSections> <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Raz or.Configuration.

RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0. 0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSec tion, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToke n=31BF3856AD364E35" requirePermission="false" /> <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorP agesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, Public KeyToken=31BF3856AD364E35" requirePermission="false" /> </sectionGroup> </configSections> <system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Ve rsion=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> <!-- Your namespace here --> </namespaces> </pages> </system.web.webPages.razor> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35 " /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> protected void Application_Start(object sender, EventArgs e) { System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(new As semblyResourceProvider()); AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes);

} public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); } public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{resource}.aspx/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.O ptional } // Parameter defaults ); }

routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.O ptional }, // Parameter defaults new[] { "FinSolutia.ProposalManager.Website.Controllers" } );

<pages ... <namespaces> <add <add <add <add <add <add namespace="System.Web.Helpers" /> namespace="System.Web.Mvc" /> namespace="System.Web.Mvc.Ajax" /> namespace="System.Web.Mvc.Html" /> namespace="System.Web.Routing" /> namespace="System.Web.WebPages"/>

<compilation debug="true" targetFramework="4.0"> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral , PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, Pub licKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, Pub licKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicK eyToken=31BF3856AD364E35" /> <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, Pu blicKeyToken=31BF3856AD364E35" /> </assemblies> para ter wizards MVC

In Solution Explorer, right-click your project name and choose Unload Project. R ight-click the project name again, and choose Edit <yourproject>.csproj (replace the angled bracket content with your project name). You ll now see the .csproj XM L file. Find the <projecttypeguids> node which contains a semicolon-separated se ries of GUIDs, and add the following value in front of the others: {E53F8FEA-EAE0-44A6-8774-FFD645390401} <ProjectTypeGuids>{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-938 4-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> Save the updated .csproj file. Then, reload the project by right-clicking its na me in Solution Explorer and choosing Reload Project.

HomeController: public ActionResult Index() { Response.Redirect("~/default.aspx", false); return null; } References: http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web -forms-vs-2010-and-net-4-0-series.aspx http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynam icDataSideBySide.aspx http://labs.episerver.com/en/Blogs/Allan/Dates/112230/2/EPiServer-Pie-with-fresh ly-cut-MVC/

Razor view: 0) Install the RazorGenerator.Mvc package 2) Add reference to RazorGenerator.Mvc in Assembly References in the embedded vi ew project 3) In the embedded view project in AssemblyInfo.cs add [assembly: PreApplicationStartMethod(typeof(FinSolutia.ApplicationBlocks.Mvc.Mvc PreApplicationStartCode), "Start")] 4) Criar PreApplicationStartCode.cs dentro das views 5) in the view to embbed set Custom toolas RazorGenerator 6) in the view to embbed set @* Generator : MvcView *@ 7) Definir isLocal no appSettings

You might also like