I need to change the URL
on my address bar.
I looked for URL Rewrite
but as far as I've seen it works for a request like this:
url.com/mypage.aspx?xp=asd&yp=okasd
and transforms that into:
url.com/mypage/asd/okasd
http://www.iis.net/downloads/microsoft/url-rewrite
That's not my scope. I already have MVC Routes
working with url.com/mypage
. The problem is that when I type that URL
I am redirected (that's the behavior I want) to url.com/otherpage/actionX?param=value
. The problem is that I still want the address bar to show url.com/mypage
. Will URL Rewrite
work for that?
I am asking because I don't know if it will work since it's an internal redirect (RedirectToAction) instead of a 'regular' access.
In case someone wonders why I can't make a route for that, as explained in my question I alread have one rule for that url.com/mypage
that redirects to a 'router' which decides what action to call.
I've seen some questions, but I don't think they cover my specific problem:
C# - How to Rewrite a URL in MVC3
UPDATE
This is my route:
routes.MapRoute(
"Profile", // Route name
"{urlParam}", // URL with parameters
new { controller = "Profile", action = "Router" } // Parameter defaults
);
Inside Router
action I redirect to the correct action according to some validation done on urlParam
. I need this behavior since each action returns a different View
.
Updated my tags since I am now using MVC4
Thanks.