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

  • Home
  • SEARCH
  • 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 8140953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:20:11+00:00 2026-06-06T12:20:11+00:00

After reviewing A LOT of questions and Internet data, I’ve solved a problem of

  • 0

After reviewing A LOT of questions and Internet data, I’ve solved a problem of mine with getting URL parameter from MVC3 application correctly.
Thing is that there wasn’t a fault in coding, but in routing (I’m not so good with routing…).
Here’s the current issue.

http://localhost:51561/Report/Details/1

This is the way my application presents Report details, which is good. But when it does it like this, I can’t get value from URL parameter, like this

Request.QueryString["id"]

But, when I manually type in URL http://localhost:51561/Report/Details?id=1 it works…
Thing is i like the first URL type, but I don’t know how to get parameter from it…

Help, please…

Update:

My Controller actions:

public ViewResult Details(int id)
    {
        Report report = db.Reports.Find(id);
        ViewBag.TestID = Request.QueryString["id"].ToString();
        return View(report);
    }

    public ActionResult Show(int id)
    {
        Report report = db.Reports.Find(id);
        var imageData = report.Image;
        return (File(imageData, "image/jpg"));
    }

My View:

<div class="display-label">Picture</div>
<div class="display-field">
   <img alt="image" src="<%=Url.Action("Show", "Report", new { id = ViewBag.TestID })%>" width="200px" />
</div>
  • 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-06T12:20:12+00:00Added an answer on June 6, 2026 at 12:20 pm

    First of all, you shouldn’t use Request.QueryString in your application. Apart from that, in the first URL, you don’t have a query string, and thus you can’t access it (also read this article on msdn about Request.QueryString).

    I also would like to suggest you to go through the basic tutorial of ASP.NET MVC3, to be found here. Many things like your question are thoroughly explained there.

    To answer your question now, in your first URL example, the 1 in the URL is a parameter of your action (the Details action). You have to add this parameter to your method (action):

    public ActionResult Details(int id)
    

    UPDATE:
    You have apparently the right action (method) declaration. Now, you can just use the parameter id. So change the Request.QueryString["id"] just by the variable (parameter) id.

    public ViewResult Details(int id)
    {
        Report report = db.Reports.Find(id);
        ViewBag.TestID = id;
        return View(report);
    }
    

    There is no need to apply ToString() on the id, you shouldn’t make it when it isn’t necessary (you might need it somewhere else, later or so). Just put it in the ViewBag as the original type.

    Your Show() method is good :). You have now the id parameter as you needed. (Try to avoid too many parentheses, it makes it look messy and now so clear.)

    public ActionResult Show(int id)
    {
        Report report = db.Reports.Find(id);
        var imageData = report.Image;
        return File(imageData, "image/jpg");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reviewing the related questions, none of them seem to address mine, so here
I am getting started with OO PHP, and after reviewing a variety of classes
After reviewing these 2 questions and Oleg great answers can jqgrid support dropdowns in
I am having some issues with logging. After reviewing JBoss Seam source code, I
After following the RoR getting started tutorial, I added another model as: $ rails
After reviewing this blog by Kirill Osenkov (How to create a generic List of
folks. I'm starting with CakePHP and after reviewing this tutorial ( http://book.cakephp.org/view/1543/Simple-Acl-controlled-Application ) and
I'm building a huffman tree for a class currently. After reviewing my available options
I know that there are several very similarly-related questions on this website, however after
I'm trying to get some JSON formatted data from a COSM feed into a

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.