Web Routes in asp.net


Route config allow us to manage the name of the URL. By default the url are based on the location path and sometimes can be a little ugly and in addition that names penalize in the search positioning. We can do the url similar to MVC but with more control (friendly url). We can define only the name and the path, the name with restrictions, etc.

Continuing with our case, we have a simple page Books/List and two additional pages, one for see details of Authors and Publishers of the book and another one for the details of the books.

We can define some restriction in the variable parameters of the url applying regular expressions as in our case with Id (of 4 numbers) or types (needs to be Author or Publisher).

1

We need to call this method from Global.asax.

At the end, our url should be something like that:

http://localhost/Books/ 0007/Author

http://localhost/Books/0007

http://localhost/Books/List

Leave a Reply

Your email address will not be published. Required fields are marked *