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

  • SEARCH
  • Home
  • 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 8862879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:50:11+00:00 2026-06-14T15:50:11+00:00

I am learning MVC (MVC4) for the first time and completing the MvcMusicStore tutorial

  • 0

I am learning MVC (MVC4) for the first time and completing the MvcMusicStore tutorial from http://www.asp.net/mvc

The tutorial is written for MVC 3 and as I am writing the following code (in my MVC4 project)

@Html.ActionLink(album.Title, "Details", new { id = album.AlbumId })

visual studio is automatically inserting ‘object’ after I type new { to give me:

@Html.ActionLink(album.Title, "Details", new object{ id = album.AlbumId })

Is one way more correct than the other or is it a difference in MVC versions to have more defined code?

  • 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-06-14T15:50:12+00:00Added an answer on June 14, 2026 at 3:50 pm

    The syntax

    new object{ id = album.AlbumId }
    

    should yield a compiler error because “id” is not a property of object.

    The syntax

    new { id = album.AlbumId }
    

    is correct. It creates an anonymous type with a property called id

    Note that in a view, you will not get a compiler error at compile time (counter-intuitive as that may seem). The view is compiled at runtime. You may see a red squiggle under the error in the view’s source code indicating a problem, but I have found that to work only sometimes.

    I have seen the same problem with Visual Studio injecting an incorrect object after new.

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

Sidebar

Related Questions

I have a simple ASP.NET MVC 3 dummy app (just learning MVC coming from
I am new to asp.net MVC, using MVC4 at the moment, learning by tutorials
I am learning MVC 3 from asp.net site. My MVC 3 application already has
Good morning, I'm learning MVC using the music store examples on the www.asp.net/mvc page,
I'm currently learning ASP.Net MVC; I'm using Visual Studio Express 2012 with MVC4 (which
I am learning ASP.NET MVC now a days and I have found that most
I'm learning asp.net mvc and found something interesting: It seems that I can't explicitly
I am playing with learning ASP.NET MVC as a non-web developer. I am trying
I'm learning MVC and ASP.NET. I have a table in which the last column
Learning asp.net mvc and whenever I worked we had to localize our application. Looked

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.