2

In my MVC project I have a controller names ProjectController and in path it looks like /project. I want to have the path for that "/proiect" .. is there any easy way to achieve that without renaming the controller class?

Thanks, Radu

2 Answers 2

7

You should be able to accomplish this with routing

routes.MapRoute(
    "Misspelling",
    "proiect/{action}",
    new { controller = "project", action = "index" }
);     
Sign up to request clarification or add additional context in comments.

Comments

1

Yes, you can modify the rewrite-rules in the Global.aspx file.

        routes.MapRoute(
            "Default", // Route name
            "proiect/{action}/{id}", // URL with parameters
            new { controller = "Project", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

3 Comments

Can I achieve that using an attribute? I did not wanted to rewrite the mappings.
I doubt ASP MVC supports that.
Im sorry, i totally didnt. I copied the default ASP MVC mappings, as you can see by the comments, and optional id stuff. I wrote my anwser first, then added the code later on. However, i've marked yours as an awnser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.