0

So I have an asp.net MenuItem user control created ( similar to what this post has ) within inside a MVC view. The user control works as expected, except the NavigateUrl.

This is the menuitem inside the usercontrol.

<asp:MenuItem Text="View Account" NavigateUrl="~/pages/account.aspx" />

The link looks fine if the user control is being rendered from a webform, it shows

http://localhost/SampleTest/pages/account.aspx

However, put the usercontrol inside the mvc view will have it rendered as

http://localhost/SampleTest/SampleTest/pages/account.aspx 

There's an extra domain name "SampleTest" in the url.

What should I do to get rid of the extra domain name?

Community
  • 1
  • 1
Kyle
  • 406
  • 7
  • 20

1 Answers1

0

you need to update your URL navigation to URL.content.

<asp:MenuItem Text="View Account" NavigateUrl="@URL.content("~/pages/account.aspx")" />

code is not tested, but you can do like these.

Bharat
  • 5,869
  • 4
  • 38
  • 58