1

Let's say I have the following rule

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

And in the controller

public ActionResult Forums(int id)
    {
        Response.Write(id); // works
        Response.Write(Request.QueryString["id"]); // doesn't

        return View();
    }

How can I get it with Request.QueryString?

1 Answer 1

6

I think you need to go through RouteData to access the routing parameters.

E.g.

Routedata.Values["id"]
Sign up to request clarification or add additional context in comments.

1 Comment

THANK YOU SO MUCH! That's exactly what I was looking for. You can't imagine how important this is for building a multi tenancy app. Thanks again.

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.