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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:44:48+00:00 2026-06-10T08:44:48+00:00

I am having an issue trying to bind 2 database values to the URL

  • 0

I am having an issue trying to bind 2 database values to the URL my global.asax file is correct as

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

        );

The issue i am having is with my controller for some reason i cannot get the Second value to return here is my controller code

public ActionResult Detail(int id,string stitle)
    {

        Article article = db.Articles.Find(id);  
      stitle = (from s in db.Articles where id == s.ArticleID select s.stitle).FirstOrDefault();

        return View(article);
    }

is there someway that i can return stitle or include it within the article since the stitle is a string value from the database.

  • 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-06-10T08:44:50+00:00Added an answer on June 10, 2026 at 8:44 am

    Only the last parameter of a route can be optional. So in your case the id parameter can no longer be optional:

    routes.MapRoute(
        "Default",
        "{controller}/{action}/{id}/{stitle}",
        new { controller = "article", action = "Index", stitle = UrlParameter.Optional }
    );
    

    Then make sure that you are generating the proper link to this action:

    @Html.ActionLink("click me", "index", "article", new { id = "123", stitle = "some-title" }, null)
    

    and the generated url should look like this:

    href="/article/index/123/some-title"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having an issue when im trying to read in a text file while
I'm having an issue trying to append a javascript file using headScript()->appendFile('file name') with
I'm having an issue trying to edit the values of a variable inside a
I'm having a bit of issue with events in prototype. I'm trying to bind
I'm having an issue trying to directly upload a file to azure blob storage.
I'm having an issue trying to load my database into an Android ExpandableList, I've
I am having an issue trying to make a small text-fantasy type game involving
I am having an issue trying to deal with timezones in the JQuery date/time
I am having an issue with trying to retrieve the contents of the view
I'm having an issue when trying to do something which should be as easy

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.