0

Good morning/Afternoon

I have a view folder with another folder and then the view name

~Views/Edit/Edit.cshtml

I would like to keep the structure like that if possible, but the problem lies within the URL

It is currently showing

http://localhost:63672/Edit/Edit/4

I would like it to show

http://localhost:63672/Edit/4 

Without the ID in the URL as well if possible, but that is a separate problem.

How do I achieve this?

My routeconfig currently shows

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Login", action = "Login", id = UrlParameter.Optional 

}

Thanks

1
  • Do you have a controller called EditController? Commented Oct 2, 2014 at 14:34

1 Answer 1

2

We can specify a route for Edit. Add this above the "Default" route currently in your routeConfig

Example

routes.MapRoute(
            "Edit", // Route name
            "Edit/{id}", // URL with parameters
            new { controller = "Edit", action = "Edit", id = UrlParameter.Optional });
Sign up to request clarification or add additional context in comments.

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.