I am working on a project for a local college using MVC3. I have came across a requirement at which I am stuck and can’t find any wayout.
Let suppose my URL is http://www.abc.com
The requirement is that if we type teacher name after the URL we get the detailed view of the teacher, like:
http://www.abc.com/john
http://www.abc.com/smith
I asked for option like http://www.abc.com/teacher=john but it has been rejected.
Is this something relevant to URL rewriting or some other wayout, as there can be many teachers in database so I can’t make methods in controllers for every teacher.
Can anyone please guide me for this scenario?
Kind Regards
I am working on a project for a local college using MVC3. I have
Share
MVC does this natively.
Just create a route for it:
Note that this will conflict with any other
/WhateverURLs (eg,/About); to avoid that, you can use myMapDefaultController()extension to map a route for a specific controller before this one.