日期:2014-05-17  浏览次数:20473 次

请教:我的首页为什么出不来呢?
1 环境:vs2012   windows2008 R2 
2 我新建了一个基本的Asp.Net MVC 4项目,
3 添加了一个控制器,同时也添加了该控制器下Action的视图(Index.cshtml)。代码如下:
    public class AccountController : Controller
    {
        //
        // GET: /Account/

        public ActionResult Index()
        {
            return View();
        }
    }
4 在Web.config中也修改了loginUrl,代码如下:
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Index" timeout="2880" />
    </authentication>
5 可我运行的时候输入:http://localhost:57738,视图就是出不来,必须要输入完整的http://localhost:57738/account/index才能出来。
不知道是什么地方还有问题,请各位指点,小弟先谢谢了!

另外,请教一下,在上面的这种环境下,如何单独的提取出MVC4的依赖包,我怀疑我的虚拟主机空间没有MVC4的运行环境,我想单独抽取出来放到bin目录下。
再次感谢!

------解决方案--------------------
在Global.asax里
 public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

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

        }