Justin Jones 21 st February 2013 Version 1.1 Setting up an MVC4 Multi-Tenant Site

Size: px
Start display at page:

Download "Justin Jones 21 st February 2013 Version 1.1 Setting up an MVC4 Multi-Tenant Site"

Transcription

1 Setting up an MVC4 Multi-Tenant Site Contents Introduction... 2 Prerequisites... 2 Requirements Overview... 3 Design Structure (High Level)... 4 Setting Up... 5 Dynamic Layout Pages Custom Attribute Setting Custom Routing & Overrides Partial Views and Strongly Typed Models IFrame Hosting Running Specific Client Scripts MVC Areas, Area Views And Partial Views MVC Area Custom Routing, Overrides and Client Specific Views Appendix A Using MVC 4 Functionality to Override Area Controllers Only Appendix B Overriding View Error Resources

2 Introduction Justin Jones In certain circumstances, you may need to distribute an MVC Application to different clients, who use shared functionality with specific customisations. A visual example of such a case is shown below. Client 1 UI Client 1 Specifics Core Functionality Client 2 UI Client 2 Specifics Having all core and client code in a single project distributed to all would be ideal. Unfortunately it is not always possible due to commercial and/or security issues. Without proper management, it also risks damaging the integrity of core functionality as client specific modifications are added. An example would be Generic functionality with if(client == client1 ) statements. One option would be to load specific parts dynamically, but this can introduce complexities you may wish to avoid (for example they are often harder to debug). This demo provides a structure that would have the functionality shown in the diagram, while avoiding some of the pitfalls mentioned above. It is not a complete business solution and is intentionally simplistic for the purpose of the demonstration. It uses only standard MVC functionality. Prerequisites To run through this tutorial, you will need Visual Studio 2012, or Visual Web Developer Express You will also need to have a basic knowledge of ASP.NET MVC. 2

3 Requirements Overview Justin Jones The list below shows general requirements deemed necessary for a multi-tenant site. Requirement 1 The system must allow for a generic version containing core functionality from which clients can have specific customisations. 2 Clients/Users must be able to have specific themes. The images must not be visible to other customers. 3 Clients must be able to set specific properties within their own project. For example, they may have certain flags (e.g. hide log out button) that they wish to set. 4 Clients must be able to change functions of default functionality (e.g. have a next button go to a different page, or have custom validation). 5 The solution must be able to support partial views. 6 The site must work in an iframe. 7 The solution must enable clients to include specific JavaScript, such as a heartbeat, which can be reached across all pages. 8 The solution should be able to support Areas in MVC. 9 MVC Areas should be able to change/override default functionality (e.g. have a next button go to a different page, custom validation) and provide client specific views (for example, one client may have paid for custom UI controls and not want competitors to have them). The rest of this document will detail how the proposed structure can meet these requirements. 3

4 Design Structure (High Level) Justin Jones The structure shown in this demo will have a generic project, to which all core functionality will be added. It will then have a client project that hooks into this functionality and makes customisations as required. In theory, many different clients could be added with their own specific customisations. The demo structure will rely only on standard.net/mvc functionality. The generic project will have all the core controllers and views. The client project will reference the generic project and map to the generic controllers. An order of preference will be provided in the MVC routings to use custom controllers/views where required. Generic views will be copied to a folder in the client when the project is built and the client project will have view registrations to ensure the views are found. While the approach is simple, it appears to meet most challenges thrown at it, and could easily be built upon. 4

5 Setting Up Justin Jones Requirement The system must allow for a generic version containing core functionality from which clients can have specific customisations. To meet this requirement, we will need to have a Generic project that is referenced by all other projects that need to use it. It will have routes that are registered with client projects in the Global.asax and build views to a temp file, so the views are readily available to any client project. To do this: 1. Create an ASP.NET MVC4 project called Generic. 2. On the next screen, ensure the project type is empty. 5

6 3. You will now have a standard MVC4 Project setup as shown below. Justin Jones 4. Set the project type to Class Library (if it not already). To do this, right click on the Generic Project, select Properties and change the Output type to Class Library as shown below. 5. In the Generic project, right click the references and add a reference to System.Runtime.Remoting and click Ok. 6

7 6. At the top level of the Generic project, add a class file called EmbeddedResourceViewEngine.cs and add the following code. Justin Jones Note: the tmp references are critical, as this is where the views will be copied to. Note2: This structure will be replaced with something more detailed when we look at areas later. using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.Mvc; namespace Generic public class EmbeddedResourceViewEngine : RazorViewEngine /// <summary> /// Set up the view locations (including the temp locations we will build to) /// and take the embedded views and put them in the tmp file. /// NOTE: This file should not need to be updated for new Areas to become part /// of the solution. /// </summary> public EmbeddedResourceViewEngine() ViewLocationFormats = new[] "~/Views/1/0.aspx", "~/Views/1/0.ascx", "~/Views/Shared/0.aspx", "~/Views/Shared/0.ascx", "~/Views/1/0.cshtml", "~/Views/1/0.vbhtml", "~/Views/Shared/0.cshtml", "~/Views/Shared/0.vbhtml", // Code above will search the client before generic. // Improved Temp Locations // The embedded view will be copied to a tmp folder // using a similar structure to the View Folder "~/tmp/views/1/0.cshtml", "~/tmp/views/1/0.vbhtml", ; PartialViewLocationFormats = new[] "~/Views/Shared/0.cshtml", //Client first not tested in demo "~/tmp/views/shared/0.cshtml", //Improved method. ; SaveAllViewsToTempLocation(); 7

8 /// <summary> /// Get the embedded views within the project and save the info to the tmp /// location. /// </summary> private static void SaveAllViewsToTempLocation() IEnumerable<string> resources = typeof(embeddedresourceviewengine).assembly.getmanifestresourcenames( ).Where(name => name.endswith(".cshtml")); foreach (string res in resources) SaveViewToTempLocation(res); /// <summary> /// Save Resource To The Temp File. /// </summary> /// <param name="res"></param> private static void SaveViewToTempLocation(string res) // Get the file path to manipulate and the filename for re-addition later. string[] resarray = res.split('.'); // rebuild split to get the paths. string filepath = String.Join("/", resarray, 0, resarray.count() - 2) + "/"; string filename = String.Join(".", resarray, resarray.count() - 2, 2); // replace name of project, with temp file to save to. string rootpath = filepath.replace("generic", "~/tmp"); //Set in line with the server folder... rootpath = HttpContext.Current.Server.MapPath(rootPath); if (!Directory.Exists(rootPath)) Directory.CreateDirectory(rootPath); //Save the file to the new location. string savetolocation = rootpath + filename; Stream resstream = typeof(embeddedresourceviewengine).assembly.getmanifestresourcestream(res); System.Runtime.Remoting.MetadataServices.MetaData.SaveStreamToFile(resStream, savetolocation); 7. Build the Generic project. 8

9 8. Create a new Client project (MVC4 Empty I have called mine Client1Basic ). 9. Once created, right click the References and add a reference to the shared (Generic) project as shown below. 9

10 10. In the client project, update the global.asax file with the code below. Justin Jones using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Http; using System.Web.Mvc; using System.Web.Routing; namespace Client1Basic // Note: For instructions on enabling IIS6 or IIS7 classic mode, // visit public class MvcApplication : System.Web.HttpApplication public static void RegisterGlobalFilters(GlobalFilterCollection filters) filters.add(new HandleErrorAttribute()); /// <summary> /// Standard Route registration. /// </summary> /// <param name="routes"></param> public static void RegisterRoutes(RouteCollection routes) routes.ignoreroute("resource.axd/*pathinfo"); routes.maproute( "Default", // Route name "controller/action/id", // URL with parameters new controller = "Home", action = "Index", id = UrlParameter.Optional // Parameter defaults ); /// <summary> /// standard application start, with additional code to call generic. /// </summary> protected void Application_Start() AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); RegisterCustomViewEngines(ViewEngines.Engines); /// <summary> /// This will add views from Generic /// </summary> /// <param name="viewengines"></param> public static void RegisterCustomViewEngines(ViewEngineCollection viewengines) viewengines.clear(); //Remove this if there are complications... viewengines.add(new Generic.EmbeddedResourceViewEngine()); 10

11 11. In the Client project, add a new controller called Home. Justin Jones 11

12 12. In the Home controller, add an empty View called Index. Add some starter text such as Hello World. 13. Right click the Client project and select Set As Startup Project. 14. Run the project to make sure all builds ok so far. 12

13 15. In the Generic project, add a controller called TestPageController and create a view for it. Leave the name as Index. Once created, add a bit of text to identify it (e.g. hello test world). 16. Right click the view, go to the properties window and SET THE VIEWS BUILD ACTION TO EMBEDDED RESOURCE! All views in the generic project must be embedded resources. If you run the project and get a View not found error it is likely the views build action property has not been set correctly. 17. In the Client project Home > Index view, create a link to the shared pages as shown below. Notice we do not need to reference Generic, the build all hooks up ViewBag.Title = "Index"; <h2>yatta!</h2> <br Link Text, Action, Controller From Shared", "Index", "TestPage") 13

14 18. If you try to run the project now, you will get an error as shown below: Justin Jones This is because the view can no longer see the base type from the web.config. 19. Update the Generic view with a reference to MVCWebPage a format you will need to follow for all generic ViewBag.Title = "Index"; <h2>yatta!</h2> It will now work : ) You will also be able to set a break point on the controller and debug everything as usual. WARNING When you deploy the project, it is highly likely you will get an error when you load the project. You need to give the APP POOL you are using (full) rights to the folder (and specifically the tmp folder) of the published site. 14

15 Dynamic Layout Pages Justin Jones Requirement Clients/Users must be able to have specific themes. The images must not be visible to other customers. NOTE: This could be used for custom themes, browsers or types (e.g. mobile). NOTE 2: The work above will mean that all views must be Embedded Resources and will be built to a file called tmp. If you get errors about missing views, you have probably not set the file to Embedded Resource. In the Client project, if you view hidden files, you will be able to see the tmp folder and the built generic views inside. 1. In Generic > Views, add a folder called Shared (if it doesn t exist already). 2. In the shared folder, create a layout page. To do this right click Shared > Add new Item > MVC 4 Layout Page. When you name the layout page (and in fact anything in the Shared folder), the convention is to use an underscore before the name e.g. _GenericLayoutPage.cshtml. 3. Set the page as an Embedded Resource. 15

16 4. Due to the embedded resource setup, the associations are broken, so you will need to add an inherits statement at the top. An example is shown System.Web.Mvc.WebViewPage <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> </head> <body> <div> I am in generic layout. </div> </div> </body> </html> 5. The LayoutPage will be called from a file called _ViewStart. ViewStart would normally contain a static reference to the layout page, but we are going to create a dynamic lookup. To do this we will need an HTML Helper. This can be extended/made classier in the future. In the Generic project, add a folder called Helpers, then a class file within that called LayoutHelper. Add the code as show below. This will be used to do a custom lookup on the layout and can be extended/altered later. using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Generic.Helpers public class LayoutHelper public static string GetLayout() // Default to the generic layout // Note the output will be in the tmp folder when published. string layoutname = "~/tmp/views/shared/_genericlayoutpage.cshtml"; return layoutname; 16

17 The current file structure will look something like the screenshot below. Justin Jones 17

18 6. We now need to create the _ViewStart page to call the layout. Right Click Views Folder > Add New Item, Select MVC 4 View Page with Layout (Razor). 7. On the next screen of the Wizard, select _GenericLayoutPage, though we will overwrite that soon. 8. Set the _ViewStart file to Embedded Resource. 18

19 9. On the file created, set it to inherit System.Web.WebPages.StartPage, add a using statement for the helper and use the Generic helper to select the layout dynamically as shown Layout =LayoutHelper.GetLayout(); 10. Run the project. When you call the page in Generic now, it will call the generic layout. 19

20 11. Now we will update the project to be able to switch to a client layout page. 12. In the Client project, add a folder - Views > Shared. In this, add another MVC4 Layout Page (Right click Shared Folder > Add > New Item > MVC4 Layout Page (Razor). Call it _ClientLayoutPage. Client Views/Layout Pages must NOT be set as an Embedded Resource and will not need an inherits statement. 20

21 13. Add a bit of code so we can differentiate it from the Generic. An example is shown below. 14. Back in the Generic LayoutHelper file, add some code that will find the client file instead of the generic. using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Generic.Helpers public class LayoutHelper public static string GetLayout() // Default to the generic layout // Note the output will be in the tmp folder when published. string layoutname = "~/tmp/views/shared/_genericlayoutpage.cshtml"; // If condition is met, use a different layout. if (1 == 1) // NOTE: Condition will be met. layoutname = "~/Views/Shared/_ClientLayoutPage.cshtml"; return layoutname; 21

22 15. Now run the project again, it will find the client layout is used instead of generic. 16. From the different layout pages, different CSS, Javascript and image files can be referenced. It would also allow you to package custom images specific to certain clients. <link rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" /> <script type="text/javascript"></script> 22

23 Custom Attribute Setting Justin Jones Requirement Clients must be able to set specific properties within their own project. For example, they may have certain flags (e.g. hide log out button) that they wish to set. To meet this requirement should be quite simple. The client project already contains a reference to the Generic project, so properties will be easily accessible. This example will just use a Singleton and the ViewBag as a proof of concept. The Singleton is likely to be a good permanent solution, but the ViewBag could probably be improved to use a ViewModel/Strongly typed view in practice. 1. To create the singleton, go to the Generic project. Add a folder called Session. Add a class within that called SessionSingleton. Create the singleton to use the.net session with just one property (a Boolean for proof of concept). You could have classes within the singleton we will just use a boolean for now. Copy and Paste in the code below. using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Generic.Session public class SessionSingleton public SessionSingleton() public static SessionSingleton _instance = new SessionSingleton(); public static SessionSingleton Instance get return _instance; public bool IsSetFromClient get return (System.Web.HttpContext.Current.Session["IsSetFromClient"]!= null)? (bool)system.web.httpcontext.current.session["issetfromclient"] : false; set System.Web.HttpContext.Current.Session["IsSetFromClient"] = value; You now have an easily accessible strongly typed store. 23

24 2. In our Generic TestPageController (created earlier in the demo), assign the Boolean property to a ViewBag property as shown below (viewbag is dynamic we have just created the Viewbag property on the fly). Note this could be improved with making a ViewModel or something like that. For now, we are happy to prove the concept. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace Generic.Controllers public partial class TestPageController : Controller // // GET: /TestPage/ public ActionResult Index() ViewBag.IsSetFromClient = Generic.Session.SessionSingleton.Instance.IsSetFromClient; return View(); 3. In the Generic TestPage > Index.cshtml view, add a statement to make the output obvious as to whether the item has been set or ViewBag.Title = "Index"; if (ViewBag.IsSetFromClient == true) <p>i am set from the client : )</p> else <p>i am NOT SET from the client : (</p> 24

25 4. Run the client. The output should look like the example below. Justin Jones 5. Now go to the client project. In the HomeController (as we know this will be hit) add some code to set the property as shown below. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace Client1Basic.Controllers public class HomeController : Controller // // GET: /Home/ public ActionResult Index() Generic.Session.SessionSingleton.Instance.IsSetFromClient = true; return View(); 6. Run the project again. It should look like the example below. 25

26 Custom Routing & Overrides Justin Jones Requirement Clients must be able to change functions of default functionality (e.g. have a next button go to a different page, or have custom validation). 1. This requirement can be achieved via a mix of MVC routing and inheritance. 2. In the Generic project Views/TestPage/Index.cshtml, add a using statement at the top System.Web.Mvc.Html 3. In the same file, add a simple form, that will post to an action. Example code ViewBag.Title = "Index"; if (ViewBag.IsSetFromClient == true) <p>i am set from the client : )</p> else <p>i am NOT SET from the client : (</p> <hr /> <!-- The HTML helper needs the using reference above.--> <!-- This code will test overriding for client specific (Html.BeginForm("Submit", "TestPage")) <input type="submit" name="btn_test" value="test Click" /> 26

27 4. Go the Generic project TestPage controller. Add an action called Submit and a virtual string method. We are going to override the virtual method later. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace Generic.Controllers public partial class TestPageController : Controller // // GET: /TestPage/ public ActionResult Index() ViewBag.IsSetFromClient = Generic.Session.SessionSingleton.Instance.IsSetFromClient; return View(); /// <summary> /// This is the method for trialling overrides /// </summary> /// <returns></returns> public ActionResult Submit() string response = BreakHereIfYouHitMe(); return RedirectToAction("Index", "Home"); /// <summary> /// NOTE: - this is virtual, as we are going to override it in the /// client project. /// </summary> /// <returns></returns> public virtual string BreakHereIfYouHitMe() string test = "break here - i am generic."; return test; 5. Run the project. The method BreakHereIfYouHitMe() will be hit. You can add a break point to make sure if you wish. 27

28 6. In the Client project, create a controller with the same name as the one in the Generic project (i.e. TestPageController). Set it to inherit from the Generic TestPageController. Add an override for the BreakHereIfYouHitMe() method E.g. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace Client1Basic.Controllers public partial class TestPageController : Generic.Controllers.TestPageController public override string BreakHereIfYouHitMe() string test = "break here - i am specific to the client."; return test; 28

29 7. At this point, the class structure is correct, but MVC will not know the correct class to map to. To sort the routings, go to the Client Global.asax, Add a route that picks up the namespace of the client. This MUST be above the default routing in the code. The way MVC works is that it will pass through the routes until it gets what it wants. In the case there are 2 items with the same name and no preference is given in the routing, the system will error. /// <summary> /// Standard & New Route Registration. /// </summary> /// <param name="routes"></param> public static void RegisterRoutes(RouteCollection routes) routes.ignoreroute("resource.axd/*pathinfo"); // NEW routes.maproute( "Client", // Route name "controller/action/id", // URL with parameters new controller = "Home", action = "Index", id = UrlParameter.Optional,// Parameter defaults null, new string[] "Client1Basic.Controllers" //NOTE: namespace to check ); // STANDARD routes.maproute( "Default", // Route name "controller/action/id", // URL with parameters new controller = "Home", action = "Index", id = UrlParameter.Optional // Parameter defaults ); 8. Put a breakpoint in the client BreakHereIfYouHitMe() method and run the project. The override will now be hit. This could be used for custom navigation, validation etc. 29

30 Partial Views and Strongly Typed Models Justin Jones Requirement The solution must be able to support partial views. This part of the solution will include partial views and also strongly typed models. It will not use.ascx user controls. The files to find code in Generic > Global.asax of this document would need to be updated for.ascx to work. As everything should be moved to the new format anyway, ascx files will not be considered. 1. In the Generic Project, create a class called StringContainer in the Models folder. This is just a dummy file for a strongly typed model. using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Generic.Models public class StringContainer public string Detail get; set; 2. Build the project. 3. In Generic > Views > Shared, right click and add a new View named _TestPartial. Check the box Create as Partial View and make it strongly typed to use the StringContainer class. The setup should look like the screenshot below. 30

31 4. Set the Partial View to Embedded Resource. 5. The top of the file will state declaration. This must be replaced with the generic inherits statement that includes a strongly typed class (due to the embedded resource not being able to see the web.config as mentioned previously). System.Web.Mvc.WebViewPage<Generic.Models.StringContainer> NOTE: the inherit is WebViewPage NOT ViewUserControl!!!!!! 6. Add something random to the file, so we know it has been System.Web.Mvc.WebViewPage<Generic.Models.StringContainer> <p>this is all i have to 7. In the Generic Project > Views > TestPage > Index.cshtml, add an instance of the partial view, with some dummy data. E.g. <hr var model1 = new Generic.Models.StringContainer() Detail = "Woo Hoo!" ; Html.RenderPartial("_TestPartial", model1); 8. Run the project. The output should look as shown in the screenshot below. 31

32 IFrame Hosting Justin Jones Requirement The site must work in an iframe. This is just a check to ensure the solution works as expected. Further checks would be required during development. To test the solution in an iframe. 1. Run the project on localhost and copy the URL. 2. Go to iframe try it yourself page (currently at ). 3. Copy in the localhost address into the iframe src and test the site. 4. The site works as expected. 32

33 Running Specific Client Scripts Justin Jones Requirement The solution must enable clients to include specific JavaScript, such as a heartbeat, which can be reached across all pages. Obviously the super simple solution for this would just be for the client to have a specific layout page and include a script in that. The problem with this is that a whole new layout may be required for just one script addition. A simple strategy has been outlined below. 1. We need to use the Generic layout for this demo, so change the LayoutHelper.cs in Generic to hit the generic layout page as shown below. Here, I have just changed the condition to something that cannot be met. 33

34 2. Now we need something that will dynamically pick up scripts from a project. In the Generic Helpers folder, create a class called ClientJavascriptHelper.cs. In it, copy and paste the following code. I have commented the code to explain what is going on. Basically, we are going to look for a folder called Javascript at the top level of the built project, find all the files in it and update the UI to reference them. using System; using System.IO; using System.Linq; using System.Text; using System.Web; namespace Generic.Helpers public class ClientJavascriptHelper /// <summary> /// This helper method will search for Javascript in a loaded project and /// register the scripts. /// This has not been implemented as an htmlhelper extension, as info on /// the web shows it will /// run a lot quicker. /// </summary> /// <returns></returns> public static HtmlString LoadClientJavascript() StringBuilder clientscriptsbuilder = new StringBuilder(); // All client specific files must be placed in a folder called // "Javascript" (we can change this if we //want) DirectoryInfo directory = new DirectoryInfo(HttpContext.Current.Server.MapPath(@"~\Javascript")); // If there is no folder or no files in the folder, don t do anything if (directory == null directory.getfiles() == null) return new HtmlString(clientScriptsBuilder.ToString()); // Get all the files in the folder var files = directory.getfiles().tolist(); // Loop through the files in the folder. Register each one as a script // in the page. foreach (var file in files) string script + file; string jswrap = String.Format("<script type=\"text/javascript\" src=\"" + script + "\"></script>"); clientscriptsbuilder.appendline(jswrap); // return the code as HTML (otherwise the Html.Encode will just output // it as text in the UI) return new HtmlString(clientScriptsBuilder.ToString()); 34

35 3. We now need the Generic Layout to call the method. Access Generic > Views > Shared > GenericLayoutPage.cshtml. You will need to add a using statement at the top for the helper class Generic.Helpers. Then call the helper method in the appropriate place. I have followed standard convention and included it in the head tag as shown Generic.Helpers <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> </head> <body> <div> I am in generic layout. </div> </div> </body> </html> The Generic project is all ready to accept client specific Javascript files. 4. Run the Client project. When you navigate to TestPage, it should look normal and if you view the source code, you will see it looks as you would expect. 5. We will now set up a client with scripts to be dynamically included. Access the client project and add a new folder called Javascript at the top level. Within that, add two Javascript files (Javascript Folder > Right Click > Add > New Item > Find Javascript file > Enter the name )as shown below. 6. Open up the first script file and add something simple like: window.onload = function () alert("hello from the client injected script!"); ; 35

36 7. Open the second script and add something that uses a different handler e.g. window.onmousedown = function () alert("hello again from the client injected script!"); ; 8. Run the project from client 1. When you navigate to the page that uses the Generic layout, the first message will appear. 9. Click OK on the message, and then click the screen again. The second message will appear. 10. View the source and you will see the scripts have been inserted in the head tag. 36

37 MVC Areas, Area Views And Partial Views Requirement The solution should be able to support Areas in MVC. This example will now go through how a Generic MVC area could easily be used within the site structure. The finalised solution shown below requires little configuration to start, with everything happening automatically after the initial setup. To set the project up for MVC Areas: 1. In the Client Project, ZERO updates are required. The work has already been done when we Registered the custom view engines as shown in the screenshot below. 37

38 2. In the Generic project, we need to update the EmbeddedResourceViewEngine to handle Area Views and Partial Area Views. The entire code for the file has been included below and is commented with details of what is happening. using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.Mvc; namespace Generic public class EmbeddedResourceViewEngine : RazorViewEngine /// <summary> /// Set up the view locations (including the temp locations we will build to) /// and take the embedded views and put them in the tmp file. /// NOTE: This file should not need to be updated in for new Areas to become part of /// the solution. /// </summary> public EmbeddedResourceViewEngine() ViewLocationFormats = new[] "~/Views/1/0.aspx", "~/Views/1/0.ascx", "~/Views/Shared/0.aspx", "~/Views/Shared/0.ascx", "~/Views/1/0.cshtml", "~/Views/1/0.vbhtml", "~/Views/Shared/0.cshtml", "~/Views/Shared/0.vbhtml", ; // Improved Temp Locations // The embedded view will be copied to a temp folder // using a similar structure to the View Folder "~/tmp/views/1/0.cshtml", "~/tmp/views/1/0.vbhtml", PartialViewLocationFormats = new[] "~/Views/Shared/0.cshtml", // Client first- not fully tested in this demo "~/tmp/views/shared/0.cshtml", //Improved method. - Get generic if no client ; // HANDLES ALL AREAS - Generically! AreaViewLocationFormats = new[] "~/Areas/2/Views/1/0.cshtml", //client Specific Tested in this Demo! "~/tmp/areas/2/views/1/0.cshtml", //Pick up generic if no client ; AreaPartialViewLocationFormats = new[] "~/Areas/2/Views/Shared/0.cshtml", //Client Specific not used in demo "~/tmp/areas/2/views/shared/0.cshtml" //Pick up generic if no client ; // Save ALL views to the tmp file location. SaveAllViewsToTempLocation(); 38

39 /// <summary> /// Get the embedded views within the project and save the info to the tmp location. /// </summary> private static void SaveAllViewsToTempLocation() IEnumerable<string> resources = typeof(embeddedresourceviewengine).assembly.getmanifestresourcenames().where(name => name.endswith(".cshtml")); foreach (string res in resources) SaveViewToTempLocation(res); /// <summary> /// Save Resource To The Temp File. /// res will enter looking like -> Generic.Areas.TestArea.Views.Home.AreaView.cshtml /// (or something simpler), /// we need to change that to look like /// ~/tmp/areas/testarea/views/home/areaview.cshtml /// and save it to the temp location. /// </summary> /// <param name="res"></param> private static void SaveViewToTempLocation(string res) //Get the file path to manipulate and the filename for re-addition later. string[] resarray = res.split('.'); string filepath = String.Join("/", resarray, 0, resarray.count() - 2) + "/"; string filename = String.Join(".", resarray, resarray.count() - 2, 2); // replace name of project, with temp file to save to. string rootpath = filepath.replace("generic", "~/tmp"); //Set in line with the server folder... rootpath = HttpContext.Current.Server.MapPath(rootPath); if (!Directory.Exists(rootPath)) Directory.CreateDirectory(rootPath); //Save the file to the new location. string savetolocation = rootpath + filename; Stream resstream = typeof(embeddedresourceviewengine).assembly.getmanifestresourcestream(res); System.Runtime.Remoting.MetadataServices.MetaData.SaveStreamToFile(resStream, savetolocation); WARNING: Following this update, you may later get an error relating to System.Web.Optimization. If so, see Appendix B Overriding View Error for a simple resolution. 39

40 3. The Generic file is now ready to handle any type of Area so let s give it a bash. Firstly, delete the two client Javascript files we created earlier (this is just because they will be annoying otherwise). Rebuild and run the solution to make sure all is well. 4. In the Generic project, right click on the project file and Add a new MVC Area (Add > Area ). Call it TestArea. The first file the designer will show you is TestAreaRegistration.cs. Note: Due to the work you did in the EmbeddedResouceViewEngine, you will not need to alter this file. 5. Add a new (empty) controller called Home in the Area > TestArea > Controllers folder (Right Click > Add > Controller). 40

41 6. Add an empty View to the controller (make sure the create strongly typed.. and partial checkboxes are not checked. 7. Set the View to be an Embedded Resource! 8. System.Web.Mvc.WebViewPage statement as with the previous generic views. Add a bit of text to identify it. The result will look like the example ViewBag.Title = "Index"; <h2>i am in the area view</h2> 41

42 9. Now go to the Client > Home > Index view. Add a link to the Generic Area as shown below. The main part is the ActionLink to the Area. Note the call is a standard MVC Area", "Index", "Home", new area = "TestArea", null) 10. Run the project. Click the link to the area from the Home Page. You should now be able to see the page you have just created. NOTE: In Windows Explorer, you will see the content has been copied into the tmp file of the Client Project with the appropriate structure. TopLevelFolder\Client1Basic\tmp\Areas\TestArea\Views\Home\Index.cshtml 42

43 11. We will now test a partial view. Justin Jones 12. In Generic > TestArea > Views > Shared, create a partial view called _TestPartialArea.cshtml (Right Click > Add > View). 13. Set it to be an Embedded Resource and set the inherits statement (shown below). Put some random identifying text System.Web.Mvc.WebViewPage I am in the area and I'm partial (screenshot) 43

44 14. Go to the Areas > TestArea > Views > Home > Index.cshtml file. Add a using statement System.Web.Mvc.Html. and a refrerence to the partial view. Note that because there is no Model in this case, we are passing the Model through as ViewBag.Title = "Index"; <h2>i am the Area View : Html.RenderPartial("_TestPartialArea", null); 15. Run the project. You should be able to see the partial view. 44

45 MVC Area Custom Routing, Overrides and Client Specific Views Justin Jones Requirement MVC Areas should be able to change/override default functionality (e.g. have a next button go to a different page, custom validation) and provide client specific views (for example, one client may have paid for custom UI controls and not want competitors to have them). Note: In MVC 4, Controllers do not actually need to be placed in specific folders ( ). We could utilise this to avoid creating whole new Areas for minor client overrides. An example is shown in Appendix A. Note 2: Registration order of areas does not appear to be an issue in this demo, however Appendix A shows a way to force registration order of areas. For Area Routing and Overrides: 1. In Generic > Areas > TestArea > Views > Home > Index.cshtml, add a simple form with a button so we can submit to a controller. This will allow us to have a function to override. An example output is shown below, with (Html.BeginForm being the bit of ViewBag.Title = "Index"; <h2>i am the Area View : Html.RenderPartial("_TestPartialArea", null); <br /> <br (Html.BeginForm("Submit", "Home", new Area = "TestArea" )) <input type="submit" name="btn_test" value="test Click" /> 45

46 2. In the controller at Generic > Areas > TestArea > Controllers > HomeController.cs, add a submit function along with a virtual method we can override later. namespace Generic.Areas.TestArea.Controllers public class HomeController : Controller // // GET: /TestArea/Home/ public virtual ActionResult Index() return View(); /// <summary> /// This is the method for trialling overrides /// </summary> /// <returns></returns> public ActionResult Submit() string response = BreakHereIfYoureInTheArea(); return RedirectToAction("Index", "Home", new Area="" ); /// <summary> /// Note - this is virtual, as we are going to override it in the client /// project. /// </summary> /// <returns></returns> public virtual string BreakHereIfYoureInTheArea() string test = "break here - i am generic."; return test; 46

47 3. Run the project to ensure the Generic function is being hit as shown below. 47

48 4. We now need to head to the Client project to create the overriding controller. In it, we will override the BreakHereIfYoureInTheArea() method, a point at which custom functionality could be provided. Note: If you will only ever override controllers, you could use the method in Appendix A. The continuing solution here will be far more flexible though. 5. In the client Project, add a new Area with the same name as in the Generic project. Area Name: TestArea 48

49 6. In the client TestArea add a HomeController to mirror the one in Generic. 7. Set it to inherit from the Generic controller, so we can override methods within that controller. Comment out the Index() ActionResult. We are not going to work with this yet. The result will look like that shown below: 49

50 8. Put a break point in the overriding method and Start Debugging. Go to the Visit Area link, then click the Test Click button. Your breakpoint in the override controller will be hit. 50

51 9. Now we have seen we can have custom overriding within controllers, we will create a custom view that will be used instead of the generic one. Note This view could use any layout it wants and could include partial views, but we are going to make it plain for simplicity. Back in our EmbeddedResourceViewEngine (see MVC Areas, Area Views And Partial Views - step 2), we set the views to look in the client project before generic. This will make it easy to create an overriding view or partial view. 10. Although not necessary, if we wanted to override the ActionResult Index() itself, this could be done by making the Generic controller virtual and the client override it as shown in the screenshots below. NOTE: If you have two Index() methods with no preference (virtual/override), MVC not know which to use and provide the following error: The current request for action on controller type is ambiguous between the following action methods) as it won t know which to use. 51

52 11. To create an overriding view, uncomment the Client s Index() ActionResult (if it is still commented out) and add a View. This will NOT need to be an embedded resource. 12. Give it the standard settings 13. In the view, add some text so we can easily identify it. 52

53 14. Comment out the Client s ActionResult to use the one from Generic (you could keep it in to create a completely custom override, but for the purpose of this demo, comment it out). 15. If you run the project, and click on the Visit Area link again, you will now be taken to the overriding view. WARNING: If you get an error here (System.Web.Optimization), see Appendix B Overriding View Error for a simple resolution. 53

54 16. Here, the new view does not contain a submit button. For the sake of completeness, we will add it now. The button could submit to the generic controller, or an override within the client controller. 17. Add a submit button to your client override view as you had done in the generic view. The result will look like the screenshot ViewBag.Title = "Index"; <h2>i am an overriding view!</h2> <br /> <br (Html.BeginForm("Submit", "Home", new Area = "TestArea" )) <input type="submit" name="btn_test" value="test Click" /> 54

55 18. Put a breakpoint in the Generic Submit() ActionResult and run the project. When you go to Visit Area and click the test button, you will be able to access the Generic controllers submit action. As you can see, the structure allows you to mix and match between client and generic functionality as required. 55

56 *** END OF DEMO *** 56

57 Appendix A Using MVC 4 Functionality to Override Area Controllers Only If you will never have overriding views, you could create your override structure in a neater way than creating a whole new area. It is highly unlikely, but this section would continue from part 4 of MVC Area Custom Routing and Overrides. 1. In the Client project, add a folder called Areas, then under that a folder called TestArea, then a folder under that called Controllers (i.e. matching the area structure in Generic).In that, add a controller called HomeController.cs. The result should look like the structure below. 2. In the client home controller file, set it to inherit from the Generic Area Home Controller and override the BreakHereIfYoureInTheArea() method. The result should look like the code shown below. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace Client1Basic.Areas.TestArea.Controllers public class HomeController : Generic.Areas.TestArea.Controllers.HomeController /// <summary> /// This is just an override so we can break here and know we are hitting /// the override controller, /// not the generic one. /// </summary> /// <returns></returns> public override string BreakHereIfYoureInTheArea() string test = "break here - i am sneaking into the area from the client."; return test; 57

58 3. We now need to update the routing so the Client override controller will be hit instead of the Generic. A bit of extra work is required here, as standard Area registration runs in an unpredictable order when using this method. The basic concept is that we are going to create a new AreaRegistrationContext for the Client Area (which will relate to the standard routing RouteTable.Routes), and then add our Client Area mapping to it (ahead of the standard Area registration). If we were to do this for another Area, we would need to create a new AreaRegistrationContext and another mapping. In future, this sort of functionality could use reflection to look up the Area/Namespace, or more simply have a dictionary of AreaName/Namespaces and loop through creating the mappings. 4. In the Client Global.asax, add a new method called RegisterAreaOverrides() below RegisterRoutes(). The code is shown below. /// <summary> /// This method will register areas in a custom manner, so we can ensure the order /// of registration is correct. /// This could be moved to a more generic method with a loop, but has been kept /// simple for ease of reading. /// </summary> public void RegisterAreaOverrides() // Important - The area name in the registration context must be the name of // the area to override. // Important - A new context must be created for each different area. AreaRegistrationContext context = new AreaRegistrationContext("TestArea", RouteTable.Routes); //Map the override route. context.maproute( "TestArea_override", //Just a unique key "TestArea/controller/action/id", //Used 'TestArea/' // as this is the area the routing will search for. new action = "Index", controller="home", id = UrlParameter.Optional, null, new string[] "Client1Basic.Areas.TestArea.Controllers" //Namespace of the overriding controller (above) ); 58

59 5. We now need to ensure this is called before the standard area registration. To do this, call RegisterAreaOverrides() above AreaRegistration.RegisterAllAreas() in Application_Start() as shown in the example below. /// <summary> /// standard application start, with additional code to call generic. /// </summary> protected void Application_Start() // Register the overrides before the areas to ensure the routing is // correct! RegisterAreaOverrides(); // This standard function will still register all non-overridden areas, // but they will be the fallback, giving the overrides precedence. AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); RegisterCustomViewEngines(ViewEngines.Engines); 6. Put a breakpoint in the overriding controller and test the Area Page. When you click the button, the override method will be hit. 59

60 Appendix B Overriding View Error Justin Jones WARNING: If you have overriding views, you may get the following error: Could not load file or assembly 'System.Web.Optimization, Version= , Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. If you do, in visual studio, go to Tools > Library Package Manager > Package Manager Console and enter the following command PM> Install-Package Microsoft.Web.Optimization -Pre More details can be found at 60

61 Resources Justin Jones Some of the main resources used are listed below Projects

MVC :: Understanding Models, Views, and Controllers

MVC :: Understanding Models, Views, and Controllers MVC :: Understanding Models, Views, and Controllers This tutorial provides you with a high-level overview of ASP.NET MVC models, views, and controllers. In other words, it explains the M, V, and C in ASP.NET

More information

When you create a new ASP.NET MVC application, the application is already configured to use URL Routing. URL Routing is setup in two places.

When you create a new ASP.NET MVC application, the application is already configured to use URL Routing. URL Routing is setup in two places. MVC :: An Introduction to URL Routing In this tutorial, you are introduced to an important feature of every ASP.NET MVC application called URL Routing. The URL Routing module is responsible for mapping

More information

Syncfusion Report Platform. Version - v Release Date - March 22, 2017

Syncfusion Report Platform. Version - v Release Date - March 22, 2017 Syncfusion Report Platform Version - v2.1.0.8 Release Date - March 22, 2017 Overview... 5 Key features... 5 Create a support incident... 5 System Requirements... 5 Report Server... 5 Hardware Requirements...

More information

For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to

For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance About the Author...

More information

MVC :: Understanding Views, View Data, and HTML Helpers

MVC :: Understanding Views, View Data, and HTML Helpers MVC :: Understanding Views, View Data, and HTML Helpers The purpose of this tutorial is to provide you with a brief introduction to ASP.NET MVC views, view data, and HTML Helpers. By the end of this tutorial,

More information

Using Visual Studio 2017

Using Visual Studio 2017 C H A P T E R 1 Using Visual Studio 2017 In this chapter, I explain the process for installing Visual Studio 2017 and recreate the Party Invites project from Chapter 2 of Pro ASP.NET Core MVC. As you will

More information

CHAPTER 2 Understanding URL Routing

CHAPTER 2 Understanding URL Routing CHAPTER 2 Understanding URL Routing URL Routing is responsible for mapping a browser request to a particular controller and controller action. By taking advantage of URL Routing, you can control how the

More information

EVALUATION COPY. Unauthorized reproduction or distribution is prohibitied ASP.NET MVC USING C#

EVALUATION COPY. Unauthorized reproduction or distribution is prohibitied ASP.NET MVC USING C# ASP.NET MVC USING C# ASP.NET MVC Using C# Rev. 4.8 Student Guide Information in this document is subject to change without notice. Companies, names and data used in examples herein are fictitious unless

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

More information

Babu Madhav Institute of information technology 2016

Babu Madhav Institute of information technology 2016 Course Code: 060010602 Course Name: Web Development using ASP.NET MVC Unit 1 Short Questions 1. What is an ASP.NET MVC? 2. Write use of FilterConfiguration.cs file. 3. Define: 1) Model 2) View 3) Controller

More information

ASP.NET MVC 3 Using C# Rev. 3.0

ASP.NET MVC 3 Using C# Rev. 3.0 ASP.NET MVC 3 Using C# Rev. 3.0 Student Guide Information in this document is subject to change without notice. Companies, names and data used in examples herein are fictitious unless otherwise noted.

More information

Lab 10: Application Architecture Topics

Lab 10: Application Architecture Topics Lab 10: Application Architecture Topics The files associated with this lab are located in the following folders: ArchitectureLab ArchitectureLabCompleted MVC 4.0: Caching, Security, and Architecture 10-1

More information

Working with Controllers

Working with Controllers Controller 1 Objectives 2 Define and describe controllers Describe how to work with action methods Explain how to invoke action methods Explain routing requests Describe URL patterns Working with Controllers

More information

INTRO TO ASP.NET MVC JAY HARRIS.NET DEVELOPER

INTRO TO ASP.NET MVC JAY HARRIS.NET DEVELOPER INTRO TO JAY HARRIS.NET DEVELOPER WHAT IS MVC? It is a powerful and elegant means of separating concerns There is no universally unique MVC pattern. MVC is a concept rather than a solid programming framework.

More information

SportsStore: Administration

SportsStore: Administration C H A P T E R 11 SportsStore: Administration In this chapter, I continue to build the SportsStore application in order to give the site administrator a way of managing orders and products. Managing Orders

More information

CSC 415 ONLINE PHOTOALBUM: THE SEQUEL ASP.NET VERSION

CSC 415 ONLINE PHOTOALBUM: THE SEQUEL ASP.NET VERSION CSC 415 ONLINE PHOTOALBUM: THE SEQUEL ASP.NET VERSION GODFREY MUGANDA In this project, you will convert the Online Photo Album project to run on the ASP.NET platform, using only generic HTTP handlers.

More information

Diving into Visual Studio 2015 (Day #5): Debugging Improvements in Visual Studio 2015 (Part 1) -Akhil Mittal

Diving into Visual Studio 2015 (Day #5): Debugging Improvements in Visual Studio 2015 (Part 1) -Akhil Mittal Diving into Visual Studio 2015 (Day #5): Debugging Improvements in Visual Studio 2015 (Part 1) -Akhil Mittal Introduction Visual Studio has always been a great IDE for code debugging. It provides a numerous

More information

Index. Bower, 133, 352 bower.json file, 376 Bundling files, 157

Index. Bower, 133, 352 bower.json file, 376 Bundling files, 157 Index A Action results. See Controllers Actions. See Controllers Application model, 986 action constraints, 1000 Areas. See Routing Arrow functions. See Lambda expressions ASP.NET Core MVC (see Model View

More information

Bringing Together One ASP.NET

Bringing Together One ASP.NET Bringing Together One ASP.NET Overview ASP.NET is a framework for building Web sites, apps and services using specialized technologies such as MVC, Web API and others. With the expansion ASP.NET has seen

More information

This tutorial is designed for software programmers who would like to learn the basics of ASP.NET Core from scratch.

This tutorial is designed for software programmers who would like to learn the basics of ASP.NET Core from scratch. About the Tutorial is the new web framework from Microsoft. is the framework you want to use for web development with.net. At the end this tutorial, you will have everything you need to start using and

More information

Dreamweaver MX The Basics

Dreamweaver MX The Basics Chapter 1 Dreamweaver MX 2004 - The Basics COPYRIGHTED MATERIAL Welcome to Dreamweaver MX 2004! Dreamweaver is a powerful Web page creation program created by Macromedia. It s included in the Macromedia

More information

Chapter 7 Detecting Device Capabilities

Chapter 7 Detecting Device Capabilities Chapter 7 Detecting Device Capabilities Just a few years ago, the world of web clients consisted of browsers running on desktops and browsers running on mobile devices. The desktop browsers offered the

More information

MVC :: Preventing JavaScript Injection Attacks. What is a JavaScript Injection Attack?

MVC :: Preventing JavaScript Injection Attacks. What is a JavaScript Injection Attack? MVC :: Preventing JavaScript Injection Attacks The goal of this tutorial is to explain how you can prevent JavaScript injection attacks in your ASP.NET MVC applications. This tutorial discusses two approaches

More information

Overview... 7 Tabs... 8 Selected Tables... 8 Load Tables Button Selected Views... 8 Load Views Button Clear Selection Button...

Overview... 7 Tabs... 8 Selected Tables... 8 Load Tables Button Selected Views... 8 Load Views Button Clear Selection Button... 1 Complete Guide to AspxFormsGen MVC 3 Table of Contents Table of Contents Overview... 7 Tabs... 8 Selected Tables... 8 Load Tables Button... 8 Clear Selection Button... 8 Selected Views... 8 Load Views

More information

Careerarm.com. Question 1. Orders table OrderId int Checked Deptno int Checked Amount int Checked

Careerarm.com. Question 1. Orders table OrderId int Checked Deptno int Checked Amount int Checked Question 1 Orders table OrderId int Checked Deptno int Checked Amount int Checked sales table orderid int Checked salesmanid int Checked Get the highest earning salesman in each department. select salesmanid,

More information

ASP.NET MVC 4 Using C# Evaluation Copy. Student Guide Revision 4.5. Object Innovations Course 4143

ASP.NET MVC 4 Using C# Evaluation Copy. Student Guide Revision 4.5. Object Innovations Course 4143 ASP.NET MVC 4 Using C# Student Guide Revision 4.5 Object Innovations Course 4143 Table of Contents (Overview) Chapter 1 Introduction to ASP.NET MVC Chapter 2 Getting Started with ASP.NET MVC Chapter 3

More information

Terratype Umbraco Multi map provider

Terratype Umbraco Multi map provider Terratype Umbraco Multi map provider Installation Installing via Nuget This Umbraco package can be installed via Nuget The first part is the Terratype framework, which coordinates the different map providers,

More information

Figure 1 Forms category in the Insert panel. You set up a form by inserting it and configuring options through the Properties panel.

Figure 1 Forms category in the Insert panel. You set up a form by inserting it and configuring options through the Properties panel. Adobe Dreamweaver CS6 Project 3 guide How to create forms You can use forms to interact with or gather information from site visitors. With forms, visitors can provide feedback, sign a guest book, take

More information

cwhois Manual Copyright Vibralogix. All rights reserved.

cwhois Manual Copyright Vibralogix. All rights reserved. cwhoistm V2.12 cwhois Manual Copyright 2003-2015 Vibralogix. All rights reserved. This document is provided by Vibralogix for informational purposes only to licensed users of the cwhois product and is

More information

Activating AspxCodeGen 4.0

Activating AspxCodeGen 4.0 Activating AspxCodeGen 4.0 The first time you open AspxCodeGen 4 Professional Plus edition you will be presented with an activation form as shown in Figure 1. You will not be shown the activation form

More information

You can call the project anything you like I will be calling this one project slide show.

You can call the project anything you like I will be calling this one project slide show. C# Tutorial Load all images from a folder Slide Show In this tutorial we will see how to create a C# slide show where you load everything from a single folder and view them through a timer. This exercise

More information

Manual Html Image Src Url Path Not Working

Manual Html Image Src Url Path Not Working Manual Html Image Src Url Path Not Working _img src="file:///absolute/path/to/rails-app/public/image.png" alt="blah" /_. However i obviously want a relative path instead. Where is the relative path going.

More information

Sitecore MVC Developer's Reference Guide

Sitecore MVC Developer's Reference Guide Sitecore MVC Developer's Reference Guide Rev: 28 February 2014 Sitecore CMS 7.2 Sitecore MVC Developer's Reference Guide A developers guide to MVC in Sitecore Table of Contents Chapter 1 Introduction...

More information

Course Outline. ASP.NET MVC 5 Development Training Course ASPNETMVC5: 5 days Instructor Led. About this Course

Course Outline. ASP.NET MVC 5 Development Training Course ASPNETMVC5: 5 days Instructor Led. About this Course ASP.NET MVC 5 Development Training Course ASPNETMVC5: 5 days Instructor Led About this Course ASP.NET MVC 5 is Microsoft's last MVC release based on both the.net Framework or.net Core 1.0 for building

More information

Quick.JS Documentation

Quick.JS Documentation Quick.JS Documentation Release v0.6.1-beta Michael Krause Jul 22, 2017 Contents 1 Installing and Setting Up 1 1.1 Installation................................................ 1 1.2 Setup...................................................

More information

Best Practice for Creation and Maintenance of a SAS Infrastructure

Best Practice for Creation and Maintenance of a SAS Infrastructure Paper 2501-2015 Best Practice for Creation and Maintenance of a SAS Infrastructure Paul Thomas, ASUP Ltd. ABSTRACT The advantage of using metadata to control and maintain data and access to data on databases,

More information

Integrate WebScheduler to Microsoft SharePoint 2007

Integrate WebScheduler to Microsoft SharePoint 2007 Integrate WebScheduler to Microsoft SharePoint 2007 This white paper describes the techniques and walkthrough about integrating WebScheduler to Microsoft SharePoint 2007 as webpart. Prerequisites The following

More information

Client Side JavaScript and AJAX

Client Side JavaScript and AJAX Client Side JavaScript and AJAX Client side javascript is JavaScript that runs in the browsers of people using your site. So far all the JavaScript code we've written runs on our node.js server. This is

More information

DarkRift Server Plugin Tutorial

DarkRift Server Plugin Tutorial DarkRift Server Plugin Tutorial Introduction This tutorial will guide you through the process of writing server plugins. It will introduce you to the server s inner architecture and will give you a good

More information

Online Activity: Debugging and Error Handling

Online Activity: Debugging and Error Handling Online Activity: Debugging and Error Handling In this activity, you are to carry a number of exercises that introduce you to the world of debugging and error handling in ASP.NET using C#. Copy the application

More information

CS354 gdb Tutorial Written by Chris Feilbach

CS354 gdb Tutorial Written by Chris Feilbach CS354 gdb Tutorial Written by Chris Feilbach Purpose This tutorial aims to show you the basics of using gdb to debug C programs. gdb is the GNU debugger, and is provided on systems that

More information

Terratype Umbraco Multi map provider

Terratype Umbraco Multi map provider Terratype Umbraco Multi map provider Installation Installing via Nuget This Umbraco package can be installed via Nuget The first part is the Terratype framework, which coordinates the different map providers,

More information

Manipulating Database Objects

Manipulating Database Objects Manipulating Database Objects Purpose This tutorial shows you how to manipulate database objects using Oracle Application Express. Time to Complete Approximately 30 minutes. Topics This tutorial covers

More information

COPYRIGHTED MATERIAL. Contents. Chapter 1: Creating Structured Documents 1

COPYRIGHTED MATERIAL. Contents. Chapter 1: Creating Structured Documents 1 59313ftoc.qxd:WroxPro 3/22/08 2:31 PM Page xi Introduction xxiii Chapter 1: Creating Structured Documents 1 A Web of Structured Documents 1 Introducing XHTML 2 Core Elements and Attributes 9 The

More information

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM CS 215 Software Design Homework 3 Due: February 28, 11:30 PM Objectives Specifying and checking class invariants Writing an abstract class Writing an immutable class Background Polynomials are a common

More information

Table of contents. Pure ASP Upload 3 Manual DMXzone

Table of contents. Pure ASP Upload 3 Manual DMXzone Table of contents Table of contents... 1 About Pure ASP Upload 3... 2 Features in Detail... 3 The Basics: Uploading Files with Pure ASP Upload 3... 14 Advanced: Using Pure ASP Upload 3 with Insert Record...

More information

Frontend guide. Everything you need to know about HTML, CSS, JavaScript and DOM. Dejan V Čančarević

Frontend guide. Everything you need to know about HTML, CSS, JavaScript and DOM. Dejan V Čančarević Frontend guide Everything you need to know about HTML, CSS, JavaScript and DOM Dejan V Čančarević Today frontend is treated as a separate part of Web development and therefore frontend developer jobs are

More information

Responsive SharePoint WSP Edition

Responsive SharePoint WSP Edition Responsive SharePoint WSP Edition Version 1.0 Bootstrap 3 and Foundation 4 for SP 2013 The Bootstrap 3 and Foundation 4 frameworks integrated with Microsoft SharePoint 2013, including several master pages

More information

Naresh Information Technologies

Naresh Information Technologies Naresh Information Technologies Server-side technology ASP.NET Web Forms & Web Services Windows Form: Windows User Interface ADO.NET: Data & XML.NET Framework Base Class Library Common Language Runtime

More information

Understanding ASP.NET MVC Model Binding

Understanding ASP.NET MVC Model Binding Page 1 of 9 Forums Community News Articles Columns Login Forgot Password Register Follow us on twitter Search MaximumASP General Business Directory More Recent Articles» ASP.NET Understanding ASP.NET MVC

More information

Quick Start - WPF. Chapter 4. Table of Contents

Quick Start - WPF. Chapter 4. Table of Contents Chapter 4 Quick Start - WPF Table of Contents Chapter 4... 4-1 Quick Start - WPF... 4-1 Using Haystack Generated Code in WPF... 4-2 Quick Start for WPF Applications... 4-2 Add New Haystack Project for

More information

Documentation for the new Self Admin

Documentation for the new Self Admin Documentation for the new Self Admin The following documentation describes the structure of the new Self Admin site along with the purpose of each site section. The improvements that have been made to

More information

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.)

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.) INTRODUCTION TO.NET Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.) CLR Architecture and Services The.Net Intermediate Language (IL) Just- In-

More information

FatModel Quick Start Guide

FatModel Quick Start Guide FatModel Quick Start Guide Best Practices Framework for ASP.Net MVC By Loma Consulting February 5, 2016 Table of Contents 1. What is FatModel... 3 2. Prerequisites... 4 Visual Studio and Frameworks...

More information

Static Webpage Development

Static Webpage Development Dear Student, Based upon your enquiry we are pleased to send you the course curriculum for PHP Given below is the brief description for the course you are looking for: - Static Webpage Development Introduction

More information

Here are the steps in downloading the HTML code for signatures:

Here are the steps in downloading the HTML code for  signatures: I. INTRODUCTION This is a guide on how you download and then install the BBB dynamic seal into your email signature. Note that the code for this type of seal is very modified to work in email and not use

More information

Table Basics. The structure of an table

Table Basics. The structure of an table TABLE -FRAMESET Table Basics A table is a grid of rows and columns that intersect to form cells. Two different types of cells exist: Table cell that contains data, is created with the A cell that

More information

Calendar Management A Demonstration Application of TopBraid Live

Calendar Management A Demonstration Application of TopBraid Live Brief: Calendar Management Calendar Management A Demonstration of TopBraid Live What you will learn in this Brief: Rapid Semantic Building Full life cycle support from model to app Ease of building User

More information

Device Detection for Content Mangement Systems (CMS)

Device Detection for Content Mangement Systems (CMS) The Power of Device Intelligence White Paper Device Detection for Content Mangement Systems (CMS) Executive Summary Many CMS platforms enable you to create content that can be effectively consumed regardless

More information

Advanced UI Customization for Microsoft CRM

Advanced UI Customization for Microsoft CRM Advanced UI Customization for Microsoft CRM Hello Microsoft CRM Gurus! Today I would like to show you some really cute tricks how to extend the User Interface (UI) of Microsoft CRM. There are great tools

More information

CHAPTER 1: INTRODUCING C# 3

CHAPTER 1: INTRODUCING C# 3 INTRODUCTION xix PART I: THE OOP LANGUAGE CHAPTER 1: INTRODUCING C# 3 What Is the.net Framework? 4 What s in the.net Framework? 4 Writing Applications Using the.net Framework 5 What Is C#? 8 Applications

More information

CONTROLLING ASP.NET MVC 4

CONTROLLING ASP.NET MVC 4 www.twitter.com/telerik www.facebook.com/telerik CONTROLLING ASP.NET MVC 4 Philip Japikse (@skimedic) phil.japikse@telerik.com www.skimedic.com/blog MVP, MCSD.Net, MCDBA, CSM, CSP Agile Practices Evangelist,

More information

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, November 2017

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, November 2017 News in RSA-RTE 10.1 updated for sprint 2017.46 Mattias Mohlin, November 2017 Overview Now based on Eclipse Neon.3 (4.6.3) Many general improvements since Eclipse Mars Contains everything from RSARTE 10

More information

2310C VB - Developing Web Applications Using Microsoft Visual Studio 2008 Course Number: 2310C Course Length: 5 Days

2310C VB - Developing Web Applications Using Microsoft Visual Studio 2008 Course Number: 2310C Course Length: 5 Days 2310C VB - Developing Web Applications Using Microsoft Visual Studio 2008 Course Number: 2310C Course Length: 5 Days Certification Exam This course will help you prepare for the following Microsoft Certified

More information

ASP.NET Using C# (VS2013)

ASP.NET Using C# (VS2013) ASP.NET Using C# (VS2013) This five-day course provides a comprehensive and practical hands-on introduction to developing Web applications using ASP.NET 4.5.1 and Visual Studio 2013. It includes an introduction

More information

CSE 143: Computer Programming II Spring 2015 HW2: HTMLManager (due Thursday, April 16, :30pm)

CSE 143: Computer Programming II Spring 2015 HW2: HTMLManager (due Thursday, April 16, :30pm) CSE 143: Computer Programming II Spring 2015 HW2: HTMLManager (due Thursday, April 16, 2015 11:30pm) This assignment focuses on using Stack and Queue collections. Turn in the following files using the

More information

CS708 Lecture Notes. Visual Basic.NET Object-Oriented Programming. Implementing Client/Server Architectures. Part (I of?) (Lecture Notes 5A)

CS708 Lecture Notes. Visual Basic.NET Object-Oriented Programming. Implementing Client/Server Architectures. Part (I of?) (Lecture Notes 5A) CS708 Lecture Notes Visual Basic.NET Object-Oriented Programming Implementing Client/Server Architectures Part (I of?) (Lecture Notes 5A) Professor: A. Rodriguez CHAPTER 1 IMPLEMENTING CLIENT/SERVER APPLICATIONS...

More information

CSC Web Programming. Introduction to JavaScript

CSC Web Programming. Introduction to JavaScript CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its

More information

Creating SDK plugins

Creating SDK plugins Creating SDK plugins 1. Introduction... 3 2. Architecture... 4 3. SDK plugins... 5 4. Creating plugins from a template in Visual Studio... 6 5. Creating custom action... 9 6. Example of custom action...10

More information

10264A CS: Developing Web Applications with Microsoft Visual Studio 2010

10264A CS: Developing Web Applications with Microsoft Visual Studio 2010 10264A CS: Developing Web Applications with Microsoft Visual Studio 2010 Course Number: 10264A Course Length: 5 Days Course Overview In this course, students will learn to develop advanced ASP.NET MVC

More information

Building Effective ASP.NET MVC 5.x Web Applications using Visual Studio 2013

Building Effective ASP.NET MVC 5.x Web Applications using Visual Studio 2013 coursemonster.com/au Building Effective ASP.NET MVC 5.x Web Applications using Visual Studio 2013 Overview The course takes existing.net developers and provides them with the necessary skills to develop

More information

Cascading style sheets

Cascading style sheets Cascading style sheets The best way to create websites is to keep the content separate from the presentation. The best way to create websites is to keep the content separate from the presentation. HTML

More information

10267A CS: Developing Web Applications Using Microsoft Visual Studio 2010

10267A CS: Developing Web Applications Using Microsoft Visual Studio 2010 10267A CS: Developing Web Applications Using Microsoft Visual Studio 2010 Course Overview This instructor-led course provides knowledge and skills on developing Web applications by using Microsoft Visual

More information

Hello everyone! Page 1. Your folder should look like this. To start with Run your XAMPP app and start your Apache and MySQL.

Hello everyone! Page 1. Your folder should look like this. To start with Run your XAMPP app and start your Apache and MySQL. Hello everyone! Welcome to our PHP + MySQL (Easy to learn) E.T.L. free online course Hope you have installed your XAMPP? And you have created your forms inside the studio file in the htdocs folder using

More information

NerdDinner Step 1: File->New Project

NerdDinner Step 1: File->New Project 1 P a g e NerdDinner Step 1: File->New Project [This is step 1 of a free "NerdDinner" application tutorial that walks-through how to build a small, but complete, web application using ASP.NET MVC. We'll

More information

AP CS P. Unit 2. Introduction to HTML and CSS

AP CS P. Unit 2. Introduction to HTML and CSS AP CS P. Unit 2. Introduction to HTML and CSS HTML (Hyper-Text Markup Language) uses a special set of instructions to define the structure and layout of a web document and specify how the document should

More information

Unifer Documentation. Release V1.0. Matthew S

Unifer Documentation. Release V1.0. Matthew S Unifer Documentation Release V1.0 Matthew S July 28, 2014 Contents 1 Unifer Tutorial - Notes Web App 3 1.1 Setting up................................................. 3 1.2 Getting the Template...........................................

More information

Implementing a chat button on TECHNICAL PAPER

Implementing a chat button on TECHNICAL PAPER Implementing a chat button on TECHNICAL PAPER Contents 1 Adding a Live Guide chat button to your Facebook page... 3 1.1 Make the chat button code accessible from your web server... 3 1.2 Create a Facebook

More information

ASP.net. Microsoft. Getting Started with. protected void Page_Load(object sender, EventArgs e) { productsdatatable = new DataTable();

ASP.net. Microsoft. Getting Started with. protected void Page_Load(object sender, EventArgs e) { productsdatatable = new DataTable(); Getting Started with protected void Page_Load(object sender, EventArgs e) { productsdatatable = new DataTable(); string connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings ["default"].connectionstring;!

More information

C# Programming: From Problem Analysis to Program Design. Fourth Edition

C# Programming: From Problem Analysis to Program Design. Fourth Edition C# Programming: From Problem Analysis to Program Design Fourth Edition Preface xxi INTRODUCTION TO COMPUTING AND PROGRAMMING 1 History of Computers 2 System and Application Software 4 System Software 4

More information

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, January 2018

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, January 2018 News in RSA-RTE 10.1 updated for sprint 2018.03 Mattias Mohlin, January 2018 Overview Now based on Eclipse Neon.3 (4.6.3) Many general improvements since Eclipse Mars Contains everything from RSARTE 10

More information

ApacheCon NA How to Avoid Common Mistakes in OFBiz Development Presented by Adrian Crum

ApacheCon NA How to Avoid Common Mistakes in OFBiz Development Presented by Adrian Crum ApacheCon NA 2015 How to Avoid Common Mistakes in OFBiz Development Presented by Adrian Crum 1Tech, Ltd. 29 Harley Street, London, W1G 9QR, UK www.1tech.eu 1 Overview Common Getting Started Problems Common

More information

DOT NET SYLLABUS FOR 6 MONTHS

DOT NET SYLLABUS FOR 6 MONTHS DOT NET SYLLABUS FOR 6 MONTHS INTRODUCTION TO.NET Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.) CLR Architecture and Services The.Net Intermediate

More information

20486-Developing ASP.NET MVC 4 Web Applications

20486-Developing ASP.NET MVC 4 Web Applications Course Outline 20486-Developing ASP.NET MVC 4 Web Applications Duration: 5 days (30 hours) Target Audience: This course is intended for professional web developers who use Microsoft Visual Studio in an

More information

Developing and deploying MVC4/HTML5 SDK application to IIS DigitalOfficePro Inc.

Developing and deploying MVC4/HTML5 SDK application to IIS DigitalOfficePro Inc. Developing and deploying MVC4/HTML5 SDK application to IIS DigitalOfficePro Inc. -------------------------------------------------------------------------------------------------------------------------------------

More information

Programming with the ASPxGridView

Programming with the ASPxGridView Programming with the ASPxGridView This year is the tenth anniversary of my VB Today column for Codeguru.com and Developer.com. (My first article was published in PC World in 1992.) In that time, during

More information

Developing for Mobile Devices Lab (Part 1 of 2)

Developing for Mobile Devices Lab (Part 1 of 2) Developing for Mobile Devices Lab (Part 1 of 2) Overview Through these two lab sessions you will learn how to create mobile applications for Windows Mobile phones and PDAs. As developing for Windows Mobile

More information

Configuring Anonymous Access to Analysis Files in TIBCO Spotfire 7.5

Configuring Anonymous Access to Analysis Files in TIBCO Spotfire 7.5 Configuring Anonymous Access to Analysis Files in TIBCO Spotfire 7.5 Introduction Use Cases for Anonymous Authentication Anonymous Authentication in TIBCO Spotfire 7.5 Enabling Anonymous Authentication

More information

INFS 2150 Introduction to Web Development and e-commerce Technology. Programming with JavaScript

INFS 2150 Introduction to Web Development and e-commerce Technology. Programming with JavaScript INFS 2150 Introduction to Web Development and e-commerce Technology Programming with JavaScript 1 Objectives JavaScript client-side programming Example of a JavaScript program The element

More information

5 Years Integrated M.Sc. (IT) 6th Semester Web Development using ASP.NET MVC Practical List 2016

5 Years Integrated M.Sc. (IT) 6th Semester Web Development using ASP.NET MVC Practical List 2016 Practical No: 1 Enrollment No: Name: Practical Problem (a) Create MVC 4 application which takes value from browser URL. Application should display following output based on input no : Ex. No = 1234 o/p

More information

Objectives. Introduction to JavaScript. Introduction to JavaScript INFS Peter Y. Wu, RMU 1

Objectives. Introduction to JavaScript. Introduction to JavaScript INFS Peter Y. Wu, RMU 1 Objectives INFS 2150 Introduction to Web Development and e-commerce Technology Programming with JavaScript JavaScript client-side programming Example of a JavaScript program The element

More information

Ad Banner Manager 8.1 User Guide. Ad Banner Manager 8.1

Ad Banner Manager 8.1 User Guide. Ad Banner Manager 8.1 Ad Banner Manager 8.1 User Guide Ad Banner Manager 8.1 User Guide... 1 Introduction... 6 Installation and configuration... 6 Upgrading... 6 Installation Steps... 7 Setting Page Permissions for the BannerAdvertisers

More information

Ruby on Rails Welcome. Using the exercise files

Ruby on Rails Welcome. Using the exercise files Ruby on Rails Welcome Welcome to Ruby on Rails Essential Training. In this course, we're going to learn the popular open source web development framework. We will walk through each part of the framework,

More information

4. Customizing CM3-IDE

4. Customizing CM3-IDE Chapter 4 4. Customizing CM3-IDE Read this chapter to learn how to customize CM3- IDE. This chapter contains information about CM3-IDE s configuration page. This chapter describes how to customize CM3-IDE.

More information

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM Objectives Defining a wellformed method to check class invariants Using assert statements to check preconditions,

More information

Simple AngularJS thanks to Best Practices

Simple AngularJS thanks to Best Practices Simple AngularJS thanks to Best Practices Learn AngularJS the easy way Level 100-300 What s this session about? 1. AngularJS can be easy when you understand basic concepts and best practices 2. But it

More information

Introducing Models. Data model: represent classes that iteract with a database. Data models are set of

Introducing Models. Data model: represent classes that iteract with a database. Data models are set of Models 1 Objectives Define and describe models Explain how to create a model Describe how to pass model data from controllers to view Explain how to create strongly typed models Explain the role of the

More information

Introduction to AngularJS

Introduction to AngularJS CHAPTER 1 Introduction to AngularJS Google s AngularJS is an all-inclusive JavaScript model-view-controller (MVC) framework that makes it very easy to quickly build applications that run well on any desktop

More information

HTML 5 Form Processing

HTML 5 Form Processing HTML 5 Form Processing In this session we will explore the way that data is passed from an HTML 5 form to a form processor and back again. We are going to start by looking at the functionality of part

More information

Form Properties Window

Form Properties Window C# Tutorial Create a Save The Eggs Item Drop Game in Visual Studio Start Visual Studio, Start a new project. Under the C# language, choose Windows Form Application. Name the project savetheeggs and click

More information