4

I have the problem that I must map a fixed URL parameter that contains an underline (e.g. purchase_id) to an controller.

    public ActionResult Index(
        long purchase_Id, 

That is working, and it's not my problem. The thing that annoys me, is the underline in the parameter name, due to the fact, that I can't change the given URL Parameter. It's called purchase_id

e.g. http://www.example.com/Order?purchase_id=12123

Is there any chance to get the following thing working, without changing the URL parameter?

    public ActionResult Index(
        long purchaseId, 

Thanks for your help.

1 Answer 1

6
public ActionResult Index()
{
    string purchaseId = Request["purchase_id"];
    return View();
}

or:

public ActionResult Index([Bind(Prefix="purchase_id")]string purchaseId)
{
    return View();
}
Sign up to request clarification or add additional context in comments.

1 Comment

Hey, that's really cool. I like the seocond version. Thanks so much.

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.