.net MVC4学习记录

一、视图

       1、为不同的Controller 建立不同的layout,

              (1)在views/shared目录下建立不同的layout文件。

              (2)在views每个控制器对应的view目录下建立_viewstart.cshtml文件,指定layout.

                

二、服务器

        1、server,mappath

                ./当前目录
          /网站主目录
          ../上层目录
          ~/网站虚拟目录

         如果当前的网站目录为E:\wwwroot   应用程序虚拟目录为E:\wwwroot\company 浏览的页面路径为E:\wwwroot\company\news\show.asp

               在show.asp页面中使用
         Server.MapPath("./")   返回路径为:E:\wwwroot\company\news
         Server.MapPath("/")    返回路径为:E:\wwwroot
         Server.MapPath("../")   返回路径为:E:\wwwroot\company
         Server.MapPath("~/")   返回路径为:E:\wwwroot\company
         server.MapPath(request.ServerVariables("Path_Info")) 
         Request.ServerVariables("Path_Translated")  
        上面两种方式返回路径为 D:\wwwroot\company\news\show.asp

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章