WebMatrix <Data> to Visual Studio

CsharpRobert 1 Reputation point
2022-12-09T02:54:11.97+00:00

How do I add WebMatrix 'Data' to Visual Studio?

Visual Studio error message

The type or namespace name 'Data' could not be found (are you missing a using directive or an assembly reference?)

My WebMatrix ajax code

Response.ContentType = "application/json";    

var record_count =  db.QueryValue (count_command);  

	var data = new List<Data> {  
    	new Data {num_of_records=record_count}  
};  

Json.Write(data, Response.Output);  
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,598 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. XuDong Peng-MSFT 11,891 Reputation points Microsoft External Staff
    2022-12-09T07:58:16.48+00:00

    Hi @CsharpRobert ,

    How do I add WebMatrix 'Data' to Visual Studio?

    Just refer to this step: Menu Bar -> Tools > NuGet Package Manager > Package Manager Console, and run following command in console:

       Install-Package Microsoft.AspNet.WebPages.Data  
    

    Once you've done that, you'll see the assembly imported into your project, something like this:
    268830-image.png

    Finally, use namespace using WebMatrix.Data; to fix your problem.

    Best regards,
    Xudong Peng


    If the answer is the right solution, please click "Accept Answer" and kindly upvote. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.