in Education by
What is Route Constraints in MVC?

1 Answer

0 votes
by

Routing is a great feature of MVC, it provides a REST based URL that is very easy to remember and improves page ranking in search engines.

 

This article is not an introduction to Routing in MVC, but we will learn a few features of routing and by implementing them we can develop a very flexible and user-friendly application. So, let's start without wasting valuable time.

 

Add constraint to URL

 

This is very necessary for when we want to add a specific constraint to our URL. Say, for example we want a URL.

 

So, we want to set some constraint string after our host name. Fine, let's see how to implement it.

 

It's very simple to implement, just open the RouteConfig.cs file and you will find the routing definition in that. And modify the routing entry as in the following. We will see that we have added “abc” before.

 
 
Most Asked ASP.NET MVC Interview Questions and Answers
 
Controller name, now when we browse we need to specify the string in the URL, as in the following:
 
Most Asked ASP.NET MVC Interview Questions and Answers

Related questions

0 votes
0 votes
    What are the methods of handling an Error in MVC?...
asked Apr 5, 2021 in Education by JackTerrance
0 votes
    What is difference between MVC and Web Forms?...
asked Apr 5, 2021 in Education by JackTerrance
0 votes
    What are the Folders in MVC application solutions?...
asked Apr 5, 2021 in Education by JackTerrance
0 votes
    What is Database First Approach in MVC using Entity Framework?...
asked Apr 5, 2021 in Education by JackTerrance
0 votes
0 votes
    What is Bundling and Minification in MVC?...
asked Apr 5, 2021 in Education by JackTerrance
0 votes
    What is Output Caching in MVC?...
asked Apr 5, 2021 in Education by JackTerrance
0 votes
0 votes
    Explain the concept of MVC Scaffolding?...
asked Apr 5, 2021 in Education by JackTerrance
0 votes
    Explain the need of display mode in MVC?...
asked Apr 5, 2021 in Education by JackTerrance
0 votes
0 votes
    How do you implement Forms authentication in MVC?...
asked Apr 5, 2021 in Education by JackTerrance
...