URL rewriting in MVC3

前端 未结 1 970
情歌与酒
情歌与酒 2021-01-15 21:35

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 www.abc

相关标签:
1条回答
  • 2021-01-15 22:20

    MVC does this natively.

    Just create a route for it:

    routes.MapRoute(
        "Teacher route",
        "/{teacher}",
        new { controller = "SomeController", action = "SomeAction" }
    )
    

    Note that this will conflict with any other /Whatever URLs (eg, /About); to avoid that, you can use my MapDefaultController() extension to map a route for a specific controller before this one.

    0 讨论(0)
提交回复
热议问题