zoukankan      html  css  js  c++  java
  • .net core 3.0 路由及区域路由与默认首页的配置

    Startup文件配置

    public void ConfigureServices(IServiceCollection services)
            {
                services.AddMvc();
            }
     public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
            {
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                }
    
                app.UseRouting();
                app.UseEndpoints(endpoints =>
                {
                    endpoints.MapControllerRoute(
                            name: "areas",
                            pattern: "{area:exists}/{controller=Default}/{action=Index}/{id?}"
                            );
                });
            }

    Controller页面

    [Area("SqlFrame")]
    public class DefaultController : Controller
    {
    public IActionResult Index()
    {
    return View();
    }
    }

    默认页面配置方案1

    在Properties下的launchSettings.json中

     "launchUrl": "SqlFrame",  设置访问的区域
    {
      "iisSettings": {
        "windowsAuthentication": false,
        "anonymousAuthentication": true,
        "iisExpress": {
          "applicationUrl": "http://localhost:50114",
          "sslPort": 44345
        }
      },
      "profiles": {
        "IIS Express": {
          "commandName": "IISExpress",
          "launchBrowser": true,
          "launchUrl": "SqlFrame",
          "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
          }
        },
        "BaseCore": {
          "commandName": "Project",
          "launchBrowser": true,
          "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
          },
          "applicationUrl": "https://localhost:5001;http://localhost:5000"
        }
      }
    }

    或者是右键解决方案 属性 

    2、默认页面 使用管道控制页面跳转

     app.UseEndpoints(endpoints =>
                {
                    endpoints.Map("/",context =>
                    {
                        context.Response.Redirect("/SqlFrame/Default/Index");
                        return Task.CompletedTask;
                    });
    
                    endpoints.MapControllerRoute(
                            name: "ss",
                            pattern: "{area:exists}/{controller}/{action}/{id?}"
                            );
                });
  • 相关阅读:
    遗传算法
    UVa 11584 Partitioning by Palindromes
    UVa1625 Color Length
    UVa10003 Cutting Sticks
    UVa1347 Tour
    UVa116 (单向TSP,多决策问题)
    uVa 12563 Jin Ge Jin Qu
    模糊综合评判
    Python进阶(5)_进程与线程之协程、I/O模型
    Python进阶(4)_进程与线程 (python并发编程之多进程)
  • 原文地址:https://www.cnblogs.com/taikongbai/p/13426423.html
Copyright © 2011-2022 走看看