Asp.net领域的mvc路由问题 [英] Asp.net Mvc areas routing issue

查看:119
本文介绍了Asp.net领域的mvc路由问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望网站的默认页是Login.cshtml。我得到异常:

I want default page of the site to be Login.cshtml. I get the Exception:

错误:认为登录或它的主人没有被发现或没有视图引擎支持搜索位置。在以下地点进行了全面搜查:

Error: The view 'LogIn' or its master was not found or no view engine supports the searched locations. The following locations were searched:

我有2个区域。结构如下所示。

I have 2 areas. Structure is shown below.

我routeconfig如下图所示。

My routeconfig is shown below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Portal.Web
{
public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "LogIn", id =   UrlParameter.Optional },
            namespaces: new[] { "Portal.Web.Areas.Management" }
        );
    }
    }

}

我的global.asax.cs如下:

My global.asax.cs is shown below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;

namespace Portal.Web
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode, 
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        WebApiConfig.Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
    }
}
}

`你有什么建议吗?

`Have you any advice?

推荐答案

我也跟着在这个岗位指令。而问题得到解决。访问 ASP.NET MVC默认网址查看

I followed instruction in this post. And problem is resolved. Visit ASP.NET MVC Default URL View

感谢大家。

这篇关于Asp.net领域的mvc路由问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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