Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:26:04+00:00 2026-05-31T01:26:04+00:00

I have my controller working in a way at the moment where the url

  • 0

I have my controller working in a way at the moment where the url comes up Home/Collections/Collection?id=1 at the moment, which was my intended functionality. However, I would now like to make the url more friendly. For example, I would like it to become Home/Collections/Summer.

I have the following code in my CollectionsController:

    public ActionResult Index()
    {
        return View(Helper.Helper.ResolvePath("Collections"));
    }


    //
    // GET: /Collections/Collection?id=1
    public ActionResult Collection(int id)
    {
        var collectionModel = ds.GetCollection(id);
        return View(Helper.Helper.ResolvePath("Collection"), collectionModel);
    }

What do I need to change to get my desired result? Without having a separate ActionResult for each collection (as it will never be a fixed number)?

And here is my Global.asax

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

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:26:05+00:00Added an answer on May 31, 2026 at 1:26 am

    You can define a route like,

     routes.MapRoute(
                "Collections", // Route name
                "Collections/{name}/{id}", // URL with parameters
                new { controller = "Collections", action = "Collection" ,id = UrlParameter.Optional } // Parameter defaults
            );
    

    Now in your CollectionsController,

    public class CollectionsController : Controller
    {      
        public ActionResult Collection(string name)
        {
          /// Your Logic here
          /// name is required parameter
          /// optionally you can add an id parameter
            return View();
        }
    
    }
    

    Now your url will be like “http://localhost:98765/Collections/Summer”

    but i dont undersdtand why you need Home in the url

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is working, but how??? I have a controller action for a post: [AcceptVerbs(HttpVerbs.Post
I have a working UITableView in my view controller. It is being successfully populated
I have controller users . In this controller I have action account which is
I am currently working in a controller called Content. In this controller, I have
On working PHP MVC, on CONTROLLER folder i have a files controller, but inside
I'm working my way into MVC at the moment, but on my To learn
I am working on a project which includes a REST API component. I have
I have a view controller which contains a table view, and which is wrapped
I have been working my way through Scott Guthrie's excellent post on ASP.NET MVC
I have a Controller and View which allow a user to 'checkout' the contents

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.