It seems simple. In an MVC view page you have an @Html.ActionLink with parameters for action, controller & route values:
@Html.ActionLink("Some text","Action","Controller", new {id=1})
but instead of rendering the text with a link to the action, it renders a link with some weird URL that isn't what you want at all.
If you use intellisense to look at the overloads for ActionLink, you'll see that the overload you've got is interpreting new {id=1}
as html attributes not as route values. You need the overload with one more parameter, which can be null:
@Html.ActionLink("Some text","Action","Controller", new {id=1}, null)
And then it works.
thank sir, lot of thankx. u guidline help me to solve my problems.
thankx again
🙂
We’ve arrived at the end of the line and I have what I need!
Ou je crois, pour être totalement honnête que j'en ai eu surtout marre qu'on veuille m'imposer quelque chose qui me semblait totalement farfelu. Et après, j'ai simplement arrêté de me poser la question…
I actually found your blog while trying to find the name of this pizza place. In 2009 I was told about this pizza place from a tour guide and thought it was incredible. I’m trying to tell my Dad the name as he’ll be in Rome soon, and I cannot figure it out. I looked at my photos and could tell from the “pizza” sign that it’s the same place. Glad to know I’m not the only one who can’t figure it out.
Excellent Approach as per required circumstances 🙂 Best Wishes
Thank you. It helped me 🙂
Hi sir,
I wanna display parameters in url as below mentioned when I submit the form.
test.com/Cal/sum/12/13
but now it is displaying as test.com/cal/sum?a=12&b=13.
please help me out
Hi madhukrishna, First check that your website *recognises* the route test.com/Cal/sum/12/13 if you type it in the browser. If your routes are set up to recognise it, then ActionLink should be able to display it. If not, try
1) http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx/
2) stackoverflow.com often gets a pretty fast response.
Cheers,
Chris
Thanks a lot for this easy and helpfully example.
Nice post, Thanks for sharing .. here if anybody want to look more details about MVC Url Rewriting .
Understanding url rewriting and url attribute routing in asp.net mvc with examples
Hope this will helps..
Really saved my time..Thank you so much for sharing good things 🙂
you saved me today .thanks a lot
Thanks…..
Thank you, kind sir!