当前位置:编程学习 > C#/ASP.NET >>

mvc的views下的多层文件夹问题

文件路径:views/show/test/Index.aspx

控制器为:

    public class TestController : Controller
    {
        public ActionResult Index(string id)
        {
                ViewData["chsword"] = id;
            return View();
        }

    }

路由为:

            routes.MapRoute(
                "Default", // 路由名称
                "show/{controller}/{action}/{id}" // 带有参数的 URL
                 new { controller = "Test", action = "Index", id = UrlParameter.Optional } // 参数默认值
            );


最后访问,http://127.0.0.1/show/Test/Index/9,提示未找到视图,这种有几层文件夹的,要如何来写呢?谢谢!! --------------------编程问答-------------------- 怎么也不见版主帮我答答问题的....等待.... --------------------编程问答-------------------- views/show/test/Index.aspx

return View(Index);

"show/{controller}/{action}/{id}" // 带有参数的 URL
                 new { controller = "Test", action = "Index", id = UrlParameter.Optional } 

不知道执行没有执行这个路由。

还没遇到过类似的情况


--------------------编程问答-------------------- views/test/Index/    这种是没问题的
就是加多个文件夹views/show/test/Index/9 ,
在路由里url样式加上  :           
"show/{controller}/{action}/{id}" ,
new { controller = "Test", action = "Index", id = UrlParameter.Optional },
就找不到路径了
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,