I have the following route definitions on my MVC3 website:
routes.MapRoute(
"FB",
"fb/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
).RouteHandler = new RH();
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
My custom RH handler code
public class RH : MvcRouteHandler
{
protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
{
return base.GetHttpHandler(requestContext);
}
}
What I want to achieve is that when my site is accessible with the fb subfile prefix, then my web logic runs a little differently.
The problem is that when I usually access my site (e.g. http: // localhost ), then when I do
Url.Action('action' 'controller')
then the output will be "http: // localhost / fb / controller / action".
I want to achieve that when my site was accessible using the 'fb' prefixed subfile, then my Url.Action calls the output / fb / controller / action path, and if I usually access the website (without the 'fb' subfile) prepath), then Url.Action calls the output / controller / action
, /fb/controller/actions /, /controller/action format.
'fb' , fb '.