Exemplo n.º 1
0
        public ActionResult ReadUserNavigationDemo()
        {
            UserContext userContext = new UserContext();

            string filePath = SysContext.Config.TempDirectory_Physical + SysContext.CommonService.CreateUniqueNameForFile("siteMapDemo.xml");

            userContext.Navigation.RootNode.Save(filePath);
            return(File(filePath, MimeHelper.GetMIMETypeForFile(".xml")));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="filePhysicalPath">文件的虚拟路径</param>
        /// <param name="downloadName">下载文件名</param>
        public FilePathResult DownloadFile(string filePhysicalPath, string downloadName)
        {
            string extension = Path.GetExtension(filePhysicalPath);

            downloadName = HttpUtility.UrlPathEncode(downloadName + extension);

            if (Request.Browser.Browser == "IE")
            {
                Response.AddHeader("Content-Disposition", "attachment; filename=" + downloadName);
            }

            return(File(filePhysicalPath, MimeHelper.GetMIMETypeForFile(extension), downloadName));
        }
Exemplo n.º 3
0
        public ActionResult ReadSiteMapDemo()
        {
            // 1.读取站点地图
            XmlNode rootNode = SysContext.NavigationNode;

            // 2.修改Xml节点
            foreach (XmlNode node in rootNode.GetChildNodes("siteMapNode", "title", "验证码组件"))
            {
                node.RemoveSelf();
            }

            // 3.将修改后的Xml节点,保存到文件,并显示在浏览器中
            string filePath = SysContext.Config.TempDirectory_Physical + SysContext.CommonService.CreateUniqueNameForFile("siteMapDemo.xml");

            rootNode.Save(filePath);
            return(File(filePath, MimeHelper.GetMIMETypeForFile(".xml")));
        }