0

I am using asp.net mvc.

here I am not asking on controller logic but at view page.And I am not messing with default setting of url routing.

I have a view having some url like /controller/action?CID=2

In this view I want to put Link having above structure but with different controller.

The point is get the current url parameter and put hyperlink with same Querystring parameter.

0

1 Answer 1

2
<%=Html.ActionLink("linkText", "actionName", 
    "controllerName", new {CID = Request.QueryString["CID"]}, null) %>

Do you mean something like this?

Sign up to request clarification or add additional context in comments.

6 Comments

Is this an "okay" thing to do in MVC? I'm not saying you're wrong, I'm just interested to know.
Actually your url format is not registered in my routing table. so I explicitly pass it like ?CID=1
The third parameter on this overload is routeValues, and a custom object like the one above is usually what's used for this purpose (passing parameters for the route).
@Vikas My url format? I just put them in there for demonstration. You, of course, need to replace them with your values.
I'm Trying to say that CID is not registered. If you registered a path with parameter as ID then you must have to pass a parameter with name ID. In my case it is CID & registered as ID
|

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.