1

I created an IOS app where a user can send invites out to people but I messed up the URL and I want to fix it with a custom route because submitting a fix will take a few days. I forgot the controller name in the URL. The URL is like the following

http://example.com/invite/R32f8f8s9f-a889f898

I need it to go to Home/invite/R32f8f8s9f-a889f898

I've tried creating a custom route but I haven't been successful. Is there a way to do it with routing?

2
  • You probably have your default route set as 'Home'. Change that to something else and the 2nd link should function as you'd like Commented Dec 3, 2014 at 16:28
  • The 2nd link is the way I want the first link to behave. I can't edit the 1st link right now because it is coming from an iOS app. Commented Dec 3, 2014 at 16:38

1 Answer 1

2

You can define a strict route without specifying a controller and placeholders and direct it your action method

routes.MapRoute(
            name: "Invite",
            url: "invite/{id}",
            defaults: new { controller = "Home", action = "Invite", id = UrlParameter.Optional }
        );

Don't forget to put it before your default route.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I haven't had to create a custom route in a while.

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.