Address: http://space.itpub.net/740297/viewspace-588774
2. create an extension method for urlhelper to map your JavaScript, stylesheet, and image folders to ASP by default. net MVC creates content and scripts folders to store them, but I do not like this method. I like the following folder organization method, which allows me to set static file caching for only one assets folder, instead of Multiple folders: assets + Images + scripts + stylesheets no matter how folders are organized, create the urlhelper Extension Method to map these folders so that you can easily reference them in the view, and, in the future, if you need to modify the folder structure, you do not have to do a lot of "Search/Replace ". We recommend that you create extension methods for resources that are frequently referenced in your view .. Example: 1. Public static string image (this urlhelper helper, string filename) 2. {3. Return helper. Content ("~ /Assets/images/{0} ". formatwith (filename); 4. } 5. 6. Public static string stylesheet (this urlhelper helper, string filename) 7. {8. Return helper. Content ("~ /Assets/stylesheets/{0} ". formatwith (filename); 9. } 10. 11. Public static string noicon (this urlhelper helper) 12. {13. Return image (helper, "noicon.png"); 14. } When referencing these resources, you can reference them as follows: 1. <Link href = "<% = URL. stylesheet (" site.css ") %>" rel = "stylesheet" type = "text/CSS"/> instead of the default one: 1. <Link href = "http://www.cnblogs.com/Content/Site.css" rel = "stylesheet" type = "text/CSS"/>
Related reading:
- ASP. net mvc unleashed (5) (continued)(Geez, 2009-3-13)
- ASP. net mvc unleashed (6)(Geez, 2009-3-17)
- ASP. net mvc 1.0 officially released(Geez, 2009-3-18)
- ASP. net mvc unleashed (6) (continued)(Geez, 2009-3-21)
- ASP. net mvc technology topics(Zhu Xianzhong, 2009-3-27)
- Action filter for ASP. net mvc notes (idotnetspace)
- ASP. net mvc: analyze the tempdata mechanism (idotnetspace)
- ASP. net mvc Futures: MVC control Overview (geez, 2009-4-09)
- ASP. net mvc Futures: local view(Geez, 2009-4-10)
- ASP. net mvc best practices (1)(Geez, 2009-4-10)