ASP.NET MVC Routing Questions -


I have just started using ASP.NET MVC and I have two routing questions.

  1. How do I install the following paths in ASP.NET MVC?

     domain.com/about-us/ domain.com/contact-us/ Domain.com/staff-bios/ 

    To keep the URL short, I use a controller in the actual URL Do not want to specify. If the URL liked it:

     domain.com/company/about-us/ domain.com/company/contact-us/ domain.com/company/staff-bios/ 

    It would be more sensible for me, because I can add a company controller and contact us about us, set up action ringtones for staff-bios and return the right ideas. What am I missing?

  2. What is the name of the default "default" in the default routing rule in ASX? Is it used for something?

Thank you!

I will answer my second question first - "default" is just a name for the path. It can be used if you ever need to reference a path by name, such as when you want to URL from a path

Now, for those URLs you want to set up , You can bypass the controller parameter until you are correct with always specifying the same controller as the default path may look like this:

  {Action} / {page}  

Be sure to have been declared after your other routes, because it will match too many URLs you do not intend to, you want to crack the first time on the other routes. Set it to:

  route. Map route (zero, "{action} / {page}", new {controller = "company controller", action = "company", page = "contact-s"}); Of course, in your MyDefault Administrator, your "Action Method" company will need the " string page " parameter, but it should do the trick for you, your company system. Only will check to see if the view was present for the page parameter, return it to 404, or see if that happens. 


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -