Implementing a lowercase routing url in an ASP. NET Core Project

Source: Internet
Author: User

In earlier versions of ASP. NET MVC, we can set routes by using the RegisterRoutes method in the app . Lowercaseurls = true; To turn the URL link of the page to lowercase. in ASP. NET Core MVC, the configuration of the route is similar to the following code:

App. USEMVC (configureroutes =>{    configureroutes.maproute ("Default", "{controller=app}/{action=index}/{id}");});

The problem is that the Configureroutes instance type does not contain properties similar to Lowercaseurls, so we cannot configure the URL lowercase feature here.

In ASP. Lowercaseurls's configuration still exists, but it needs to be configured in another place. To implement a routing URL that implements lowercase in an ASP. NET Core project, we just need to add code to the Configureservice method of the Startup class.

Services. addrouting (options = options. Lowercaseurls = True);

This article was released on September 29, 2017 and was tested in the NETCOREAPP2.0 + Aspnetcore 2.0 platform and is running well.

Implementing a lowercase routing url in an ASP. NET Core Project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.