Net Core empty project shows Controller Error [duplicate] - c#

This question already has answers here:
'CompanyName.Foo' is a 'namespace' but is used like a 'type'
(8 answers)
Closed 6 years ago.
When I start a new empty project there is an error in the .net core project:
Controller is a namespace but is used like a type.
Am I missing some packages?

You're right, you've missed Microsoft.AspNetCore.Mvc package. Just add it to project.json and things will be OK.

Related

Using Powershell in C# [.NET 6] [duplicate]

This question already has answers here:
`PowerShell.Create()` returning null
(3 answers)
Closed last year.
I migrated from .NET Framework 4.8 to .NET 6.
System.Management.Automation.PowerShell.Create();
now returns null.
Is there a new package i need to reference or other solution?
Removing the old References and adding the NuGet package
Microsoft.PowerShell.SDK solved this issue.

Class,Methods in C# Namespaces [duplicate]

This question already has answers here:
display classes of a namespace in visual studio (C#)
(3 answers)
Closed 2 years ago.
How can I see all class and methods in any namespace? For example : I install some nuget api and using this namespace of api. I want to know which class and methods are include this namespace
Maybe the Object browser in Visual Studio is what you want? In the menu of Visual Studio under View?

System.Web.Mvc.HttpPostAttribute vs System.Web.Http.HttpPostAttribute? [duplicate]

This question already has answers here:
What is the different between System.Web.Http.HttpPut Vs System.Web.Mvc.HttpPut
(2 answers)
Closed 3 years ago.
In my Web API project which is based on the ASP.NET MVC, I want to use the HttpPost attribute. When I've added that onto the action, The IntelliSense suggests me these two namespaces:
System.Web.Mvc.HttpPostAttribute
System.Web.Http.HttpPostAttribute
Which one should be used and why?
Prior to ASP.NET Core, MVC and WebAPI were mainly separate libraries.
The .Mvc namespace applies to MVC controllers, the .Http namespace to Web API controllers.

HttpUtility.HtmlDecode() [duplicate]

This question already has answers here:
HttpUtility does not exist in the current context
(10 answers)
Closed 5 years ago.
I'd like to use HttpUtility.HtmlDecode() to process some strings in my application, but for some reason Visual Studio doesn't seem to know where it's at.
I'm fairly new to C# so I'm just guessing I've missed something like importing a library, but I don't even know what to Google.
I've tried using System.Web but it only seems to contain AspNetHostingPermission and friends, no HttpUtility.
I'm using VS2015 Community Edition on a Windows 10 machine.
I've tried "using System.Web" but it only seems to contain "AspNetHostingPermission" and friends, no HttpUtility.
You simply need to reference the DLL System.Web, right click References > Add Reference > Assemblies > Framework > System.Web
Also check you're not targeting the Client Profile, in which System.Web.dll is not available. You can target the full framework in Project Properties.

Class library C# [duplicate]

This question already has answers here:
C# using others code
(4 answers)
Closed 5 years ago.
I made a blank solution in C#( without any project ) and I added two Class Library Projects named "PersonLibrary" and "AnotherLibrary". The problem is that when I try to access the PersonLibrary from AnotherLibrary with: "using PersonLibrary;" I get this error: The type or namespace name "PersonLibrary" could not be found.
1
If you go to AnotherLibrary -> References -> Add Reference, you should see an option to add projects in solutions and add PersonLibrary .
Once you add a reference, You can use whatever the available methods.

Categories