Wish you were doing ASP.NET MVC but stuck with a brownfield WebForms app. How to integrate MVC into an existing WebForms app. Whats possible, where the challenges are and what you need to think about to overcome them.
to VS2010/VS2012 – Project conversion wizard • Upgrade to CLR4. – <httpRuntime requestValidationMode="2.0" /> • Better in 4.5 Request.Unvalidated.Form – <trust legacyCasModel="true" /> • No dynamic if you do this. – http://www.asp.net/whitepapers/aspnet4/breaking- changes – http://www.asp.net/vnext/overview/aspnet/whats-new
PROJECT • Bunch of steps. – Add references to OVER 9000 assemblies. – Add /Controllers and /Views projects – Add junk to web.config – Add {9000-000-0000} guids to .csproj file for VS Tooling. OR • Just - nuget - AddMvc3ToWebForms
2. Routing HTTP Handler executes, matching based on routes 3. MVC Route Handler executes controller & action 4. The ViewPage is rendered (assuming your calling RenderView) 5. The ASP.NET page life cycle is invoked
Razor views. • Razor _Layout.cshtml with WebForm.aspx views. • Both are possible – google will help. Both have some limitations. • http://www.eworldui.net/blog/post/2011/01/07/Using- Razor-Pages-with-WebForms-Master-Pages.aspx
to use it. • Make sure your escaping user input (XSS). Use the WebForms 4 escaping stuff <%: %> NOT <%= %> • Mass assignment vulnerabilities (ala github). ALWAYS Use a ViewModel – don’t bind to Database models directly. • Insecure direct object references (e.g. /users/21) • Know the OWASP Top 10 – https://www.owasp.org/index.php/Top_10_2010