简体   繁体   中英

Default template for ASP.NET project in VS Community 2019 not working

So a little bit of context here, I'm completely new to C# and ASP.NET, I was following this video to help setup my project and learn the basics. I downloaded VS Community 2019 (I usually use VS Code) and tried to create a new project, the creation process is not exactly the same as the video (I assume it's a difference from Visual Studio to Visual Studio Community) but I thought that it's not different enough to be a problem. Right after creating the project, I tried running it to check that everything is fine, but it said that there are build errors and asked if I want to run it anyway, I said yes, that's when I got this error:

浏览器出错

I assume it's a generic error that doesn't explain what exactly went wrong, so I went to check what those build errors are, and to my surprise, there are a lot of them :

VS 社区中的错误

I copied some of them to look for a reason why this is happening but haven't found anything meaningful so here am I, asking here. Any ideas ?

Thank you for reading.

Edit : I recreated a project with Authentication Type "None" and it works without any problem. Retried after that with Authentication Type "Individual Accounts" and I get the build errors again. Is there something missing in my PC that I need to install or add to the project ?

I'll try to answer this as accurate as possible;

but it said that there are build errors and asked if I want to run it anyway, I said yes, that's when I got this error

This will not work. The build must succeed (at least once) in order to be able to start.

The difference might be due to a different version of visual studio, or a different template. The errors suggest you are missing some nuget packages or references.

Best you can do is find an up to date tutorial or follow the steps very precise.

Alternatively, you can start with a simple default template - those should work out of the box and you can build from there.

Alright, finally found the problem, like Stefan said, it's a NuGet package problem. There was no online source for the packages, so I added it like this :

NuGet 包

After that, you go to Project -> Manage NuGet packages -> Updates -> Select all packages and update. Then you need to create a new project (already created ones don't work and I don't exactly know why).

The snapshot you posted with the errors tells you exactly what's wrong. You are missing the packages as they don't exist in the local cache.

Try this:

Go to Menu Tools > Nuget Package Manager > Manage Nuget Packages for Solution...

On the new window that opens, verify that the Package Source combo box in the top right corner is set to "nuget.org" or "All".

That should allow Visual studio to go to the web looking for the missing packages and restore them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM