Don't you just love crazy weirdness when you create urls? I sure do....NOT! Sometimes the smallest things can provide you with the biggest pain - especially when you are pressed for time. I ran across a crazy little problem in ASP.NET MVC 2 with an url I created using Html.Actionlink.
I wanted an url that looked like this -
http://www.mysite.com/Project/Pages/someGuidId.
I used the following Html.Actionlink -
<%= Html.ActionLink("View Project Pages", "Pages", "Project",
new { id = page.PageId })%>
This generated an url with a Length property at the end of it -
http:/www.mysite.com/Project/Pages?Length=7
What in the world is that? Length is NOT my friend! Fear not though! This error is very easy to solve with minimal effort. Adding one value makes the difference. I just needed to change my Html.Actionlink to the following:
<%= Html.ActionLink("View Project Pages", "Pages", "Project",
new { id = page.PageId }, null)%>
That nice little null does the trick quite nicely and makes everyone happy!
Smooches,
Kila
Problem:
<%= Html.ActionLink("View Project Pages", "Pages", "Project",
new { id = page.PageId })%>
generates http:/www.mysite.com/Project/Pages?Length=7
Solution:
<%= Html.ActionLink("View Project Pages", "Pages", "Project",
new { id = page.PageId }, null)%>
This blog is for all Microsoft & .net lovers who may find themselves in need of help or information once in a while. We all have questions and we all need to know more than we know right now. When I come across things that I think may be useful, I post it. When I have something to say that I think is important, which is everything, I post it. All of my C#, ASP.NET, VB, AJAX & programming friends around the world are welcome to the info in my blog - Ramblings Of A Crazy DotNet Woman!
Subscribe to:
Post Comments (Atom)
1 comment:
You just saved me a major headache trying to convert my project! Had no idea what was wrong with my MVC urls!
Post a Comment