Mehdi Souregi
Mehdi Souregi

Reputation: 3265

Rewriting URLs without using IIS

I've been looking for a while on how to rewrite URLs , I've seached on it in SO and Google but in vain.

My problem is that I have a small web application and I want to rewrite all my urls

So basically I want this :

localhost:56789/Controller1/Action1 => localhost:56789/something
localhost:56789/Controller1/Action2 => localhost:56789/something2
localhost:56789/Controller2/Action2 => localhost:56789/something3

...

Is it possible ? How ?

Thanks for your help :)

Upvotes: 0

Views: 43

Answers (1)

Mister Epic
Mister Epic

Reputation: 16743

Open up /App_Start/RouteConfig.cs

Add this:

 routes.MapRoute(
    name: "Something",
    url: "something", //Don't prefix this with a forward slash
    defaults: new { controller = "Cotnroller1", action = "Action1" }
 );

You can do pretty much anything with URLs these days.

ref: http://www.asp.net/mvc/tutorials/older-versions/controllers-and-routing/asp-net-mvc-routing-overview-cs

Upvotes: 3

Related Questions