Changing URL with Routing, ASP.NET MVC -


I'm still very new to routing with ASP.NET mvc, so maybe it's clear and just answer me Is missing ..

I have a controller called 'Page', and he has many action results, 'information', 'history' etc. Each action results a string, and from that, it is named after a view-based string ...

Page / Information / Page / Information / Product Page / History / About Employee

etc. The name of the controller has been 'Page', of course. I am thinking that I can use routing to remove the 'page' portion of the URL in favor of the user, just for a more user-friendly approach?

Yes, you can:

  context.MapRoute ("Pages_History_Employees", "History / Employees", // URL Parameter new {controller = "page", action = "history"}); Just specify the controller as the page and specify the URL you want as the second parameter. What is it saying that I want to take the History / Employee URI in the way of the Page Controller and want to use the History Action to handle this route. 

Just be careful that if you have a default MVC route, it appears at the end of your routes or it will match this route first. You will then get an error because it will look for the History Controller with the Employee Controller.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -