如何在mvc3 razor应用程序中设置默认页面 [英] How to set default page in mvc3 razor application

查看:308
本文介绍了如何在mvc3 razor应用程序中设置默认页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



在我的项目中使用mvc3 razor应用程序。我的问题是我在根文件夹下有1个主根文件夹3个子文件夹在那里,每个子文件夹有1个控件。那么如何在特定控件下设置默认页面。

文件夹名称是Administrator,Customer,Merchant和我的根文件夹是区域。现在如何在Customer文件夹Customercontrol中设置默认页面''Newcustomer.cshtml''。我在golbal.asax页面中这样的代码

hi all,

am using mvc3 razor application in my project. my problem is i have 1 main root folder under root folder 3 sub folders are there, each sub folder have 1 control. so how to set the default page under particular control.
folder names are Administrator,Customer,Merchant and my root folder is areas. now how set the default page ''Newcustomer.cshtml'' in Customer folder Customercontrol. my code like this in golbal.asax page

routes.MapRoute(
                "custom", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index",id = UrlParameter.Optional }// Parameter defaults

            );



但是我得到了这样的错误

~ / Views / Customer / Newcustomer。 aspx

~ / Views / Customer / Newcustomer.ascx

~ / Vi ews / Shared / Newcustomer.aspx

~ / Views / Shared / Newcustomer.ascx

~ / Views / Customer / Newcustomer.cshtml

~ /Views/Customer/Newcustomer.vbhtml

~ / Views / Shared / Newcustomer.cshtml

~ / Views / Shared / Newcustomer.vbhtml



http:// localhost:2023 /客户/客户/新客户

输入就像这样打开我的默认登录页面





请帮帮我..

谢谢


but i got the error like this
~/Views/Customer/Newcustomer.aspx
~/Views/Customer/Newcustomer.ascx
~/Views/Shared/Newcustomer.aspx
~/Views/Shared/Newcustomer.ascx
~/Views/Customer/Newcustomer.cshtml
~/Views/Customer/Newcustomer.vbhtml
~/Views/Shared/Newcustomer.cshtml
~/Views/Shared/Newcustomer.vbhtml

http://localhost:2023/Customer/Customer/Newcustomer
am enter like this open my default login page


please help me..
thanks

推荐答案





默认路由名称始终指向MVC3中的默认页面。



routes.MapRoute (

默认,//路线名称

{controller} / {action} / {id},//带有的URL参数

new {controller =Home,action =Index,id = UrlParameter.Optional} //参数默认值

);
Hi,

"Default Route" name always points the default page in MVC3.

routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);


这篇关于如何在mvc3 razor应用程序中设置默认页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆