2012-09-20 33 views
0

我在我的项目中有两个区域:管理员,成员 ,我在视图文件夹中有Login.csthml。为此 ,其地址是:我如何获得我的登录页面?

http:localhost.com:5555/Areas/Members/view/Login.cshtml

我要创造我的网站的首页文字链接“登陆”, 当我点击它,它应该去登录,我上面说的页面。

我用这个代码: @ Html.Action( “登录”, “会员”)

但是,它不知道它应该去会员区,它抛出一个错误:

{"The view 'Login' or its master was not found or no view engine supports the searched locations. The following locations were searched:\r\n~/Views/Members/Login.aspx\r\n~/Views/Members/Login.ascx\r\n~/Views/Shared/Login.aspx\r\n~/Views/Shared/Login.ascx\r\n~/Views/Members/Login.cshtml\r\n~/Views/Members/Login.vbhtml\r\n~/Views/Shared/Login.cshtml\r\n~/Views/Shared/Login.vbhtml"}

我该怎么办?

回答

0

您是否在Global.asax上注册了区域?右键单击项目并使用向导添加区域时,所有编码都会自动完成。

而且您发布的地址是不正确的......应该是http:本地主机:端口]/[AREANAME] /会员/登录

尝试使用这个网址的形式,看是否路由工作或没有

+0

是的,我有global.ascx默认的溃败: **公共静态无效的RegisterRoutes(RouteCollection路线) { routes.IgnoreRoute( “{}资源个.axd/{*} PATHINFO”); routes.MapRoute( “Default”,//路线名称 “{controller}/{action}/{id}”,//带参数的网址 新{controller =“home”,action =“Index”,id = UrlParameter.Optional},//参数默认值 new [] {“EshopTheme.Controllers”} ); } ** – Smo

+0

我认为如果您使用pastebin或任何其他工具来放置代码或将其添加到问题上会更容易。我会很有用seein你的global.asax和你的[AreaName] AreaRegistration.cs – pollirrata

+1

谢谢pollirrata,我通过添加routeValues找到我的答案: @ Html.ActionLink(linkText:“Login”,actionName:“login”,controllerName:“成员“,routeValues:new {Area =”Members“},htmlAttributes:null) – Smo

相关问题