1

I use the following route configuration in my MVC project:

var json = routes.MapRoute(
    name: "DefaultJson",
    url: "json/{controller}/{action}/{id}",
    defaults: new { ... }
);

json.DataTokens["force-json-result"] = new object();

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { ... }
);

This is used in a dev environment, the idea is to allow the view designers to see the entire model passed to the view without having Visual Studio.

If I use the Url resolver the first route will be used. For example, the following command

@Url.Action("Action", "Controller")

will print

/json/Controller/Action

Is there any way to ignore my first route during Url resolving?

2 Answers 2

2

One way is to use Url.RouteUrl. Using that you can specify a particular route name and then generate the url.

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

1 Comment

I ended using query string because of other difficulties. But this seem to be best solution.
0

I don't know of a way to do what you're asking but have solved the problem in a different way by adding a piece to my layout page which will output the model in json to a hidden div when the site is in development mode.

The same information is available and the developer doesn't have to switch urls to debug.

Comments

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.