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 7493365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:54:57+00:00 2026-05-29T16:54:57+00:00

I am new to MVC3 and cannot move with this problem. I am making

  • 0

I am new to MVC3 and cannot move with this problem.
I am making a simple blog with posts, that are divided into categories and each post may have some tags.
If I show posts to user, I have paging there, where url is like localhost/Posts/1, where “1” is number of the page.
But how can I do this if I want to show posts only from some category or with some tag?
It is in format localhost/Posts/Categories/1, where “1” is id of the category or localhost/Posts/Tags/tag1 where “tag1” is particular tag
I would like to change it all to be in format localhost/Posts/Page/1 or localhost/Posts/Categories/1/Page/1 or localhost/Posts/Tags/tag1/Page/1, but I really cannot find out how to achieve this in controller.
So my question is: How to make methods in controller to accept these complex urls?

I guess it has something to do with routing, but couldn’t find any explanation of my problem.

Thanks a lot for any help.

My code:

public ActionResult Tags(string id)
{
  Tag tag = GetTag(id);
  ViewBag.IdUser = IDUser;
  if (IDUser != -1)
  {
    ViewBag.IsAdmin = IsAdmin;
    ViewBag.UserName = model.Users.Where(x => x.IDUser == IDUser).First().Name;
  }
  return View("Index", tag.Posts.OrderByDescending(x => x.DateTime));
}

public ActionResult Index(int? id)
{
  int pageNumber = id ?? 0;
  IEnumerable<Post> posts =
            (from post in model.Posts
             where post.DateTime < DateTime.Now
             orderby post.DateTime descending
             select post).Skip(pageNumber * PostsPerPage).Take(PostsPerPage + 1);
  ViewBag.IsPreviousLinkVisible = pageNumber > 0;
  ViewBag.IsNextLinkVisible = posts.Count() > PostsPerPage;
  ViewBag.PageNumber = pageNumber;
  ViewBag.IdUser = IDUser;
  if (IDUser != -1)
  {
    ViewBag.IsAdmin = IsAdmin;
    ViewBag.UserName = model.Users.Where(x => x.IDUser == IDUser).First().Name;
  }
  return View(posts.Take(PostsPerPage));
  }
  • 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-29T16:55:01+00:00Added an answer on May 29, 2026 at 4:55 pm

    Create new routes to direct those URL patterns to your controller (or another contoller, as appropriate)

    http://www.asp.net/mvc/tutorials/older-versions/controllers-and-routing/asp-net-mvc-routing-overview-cs

    For example, this route definition

       routes.MapRoute(
                    "CategoryPage",                                              // Route name
                    "Posts/Categories/{CategoryID}/Page/{PageID}",                           // URL with parameters
                    new { controller = "Home", action = "ViewPage", CategoryID = "", PageID="" }  // Parameter defaults
                );
    

    Would be picked up by this action in the HomeController:

    public ActionResult ViewPage(int CategoryID, int PageID)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot find a solution with this problem. I have to join TWO MVC3
I am new in spring mvc3,and I am trying to create a simple project
I am somewhat new to MVC 3 so this could be something simple. I
New to javascript/jquery and having a hard time with using this or $(this) to
new Date(05-MAY-09 03.55.50) is any thing wrong with this ? i am getting illegalArgumentException
New day, new problem :-) Code: Client Side: void abw_Closed(object sender, EventArgs e) {
I just created a new project in MVC3 using EF4 code first deployed on
I am using asp.net mvc3. I am making a bitmap using text by system.drawing.
Having issues getting myself started on MVC3 Trying to define a simple route here
I've created a new site using mvc3 and now I'm getting closer to the

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.