Sunday, September 4, 2016

MVC - Redirect All traffic to one controller

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{*url}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }


HttpContext.Request.Url
{http://redirecttoexternal.se/dinmamma/whatever/?d=1}
    AbsolutePath: "/dinmamma/whatever/"
    AbsoluteUri: "http://redirecttoexternal.se/dinmamma/whatever/?d=1"
    Authority: "redirecttoexternal.se"
    DnsSafeHost: "redirecttoexternal.se"
    Fragment: ""
    Host: "redirecttoexternal.se"
    HostNameType: Dns
    IdnHost: "redirecttoexternal.se"
    IsAbsoluteUri: true
    IsDefaultPort: true
    IsFile: false
    IsLoopback: false
    IsUnc: false
    LocalPath: "/dinmamma/whatever/"
    OriginalString: "http://redirecttoexternal.se:80/dinmamma/whatever/?d=1"
    PathAndQuery: "/dinmamma/whatever/?d=1"
    Port: 80
    Query: "?d=1"
    Scheme: "http"
    Segments: {string[3]}
    UserEscaped: false
    UserInfo: ""

No comments:

Post a Comment