Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6736443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:07:48+00:00 2026-05-26T11:07:48+00:00

I am using ASP.NET MVC 3, with the Razor engine. I have a partial

  • 0

I am using ASP.NET MVC 3, with the Razor engine. I have a partial view that contains one line:

@Html.ActionLink(ViewData["UserNameIfLoggedIn"], "Index", "Home")

This partial view is rendered in my _Layout.cshtml view. The snippet that calls the controller/action is this:

@{Html.RenderAction("UserLoggedIn", "User");}

I get a compilation error, stating:
‘System.Web.Mvc.HtmlHelper’ does not contain a definition for ‘ActionLink’ and the best extension method overload ‘System.Web.Mvc.Html.LinkExtensions.ActionLink(System.Web.Mvc.HtmlHelper, string, string, object)’ has some invalid arguments

I have made a similar call (same amount of arguments and same parameter datatypes) in another MVC application (a tutorial) and it executed just fine. What could be causing this?? Why is this not working now?

I know this is probably an extremely rookie MVC question, but I cannot figure this one out.

EDIT: The solution is this:

@Html.ActionLink(ViewData["UserNameIfLoggedIn"].ToString(), "Index", "Home")

I just needed to call the ToString() method to get the parameter as a string.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:07:49+00:00Added an answer on May 26, 2026 at 11:07 am

    You need a string as your first parameter in ActionLink, I am not sure but I think ViewData is a dictionary.

    Try this just as a test

    @Html.ActionLink("test", "Index", "Home")
    

    If that works, then you need to loop through ViewData and get all the single values, and pass them as string. I am not sure what is your ViewData, though.

    If you want just a single value, use ViewBag instead.

    http://brendan.enrick.com/post/Difference-Between-ViewBag-and-ViewData-in-MVC-3.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ASP.NET MVC 3 with the Razor view engine . I have
I'm using ASP.Net MVC 3 with the Razor engine. I have an html helper
I am using ASP.NET MVC 3 with the razor view engine. I have the
I am using ASP.Net MVC 3 Razor view engine. I have a requirement to
Using ASP.NET MVC 2.0, I have an actionlink that is used for comments on
I'm experimenting with an ASP.NET MVC 3 site, using razor as the view-engine. I
I am using Razor view engine in ASP.Net MVC 3 RC 2. This is
I've got a large site that runs in ASP.NET MVC using the Razor view
I am programming using ASP.NET MVC 3 with Razor view engine. Here's what I'd
When I try to add a partial view using asp.net mvc 3 and razor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.