1

I am trying to make it possible so if someone tryes to go to /content they are sent to a specfic controller (in this case content and then the following details after in the url are passed as parameters.

the url is http://localhost:51118/content/1/7/test.html

i have tried:

routes.MapRoute("content", "content", new { controller = "Content", action = "Index", id = UrlParameter.Optional });

im trying to integrate a cms thats why the url is what it is

EDIT:

public class ContentController : Controller
{    
        public ActionResult Index()
        {
            var model = new Content();     
             return View(model);
        }
}

1 Answer 1

2

Your route is not correct. You will get routed to the Content controller only when you will access the http://localhost:51118/content url. If you want to specify more paramateres you should add more sections to your route. routes.MapRoute("content", "content/{id1}/{id2}/{content}", new { controller = "Content", action = "Index"});


public class ContentController : Controller
{    
        public ActionResult Index(int id1, int id2, string content)
        {
            var model = new Content();     
             return View(model);
        }
}
Sign up to request clarification or add additional context in comments.

1 Comment

how do i get the id's out on my controller?

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.