我正在按照Microsoft Tutorial添加控制器,遇到了以下错误:
1)编码类型或命名空间名称‘CS0234’在命名空间'System.Text‘中不存在(是否缺少程序集引用?)。
2) CS0103名称'HtmlEncoder‘在当前上下文WebMVC2中不存在
下面是我目前拥有的代码:
using System.Web.Mvc;
using System.Text.Encodings.Web;
namespace WebMVC2.Controllers
{
public class HelloWorldController : Controller
{
// GET: /HelloWorld/
public string Index()
{
return "This is my default action...";
}
// GET: /HelloWorld/Welcome/
public string Welcome(string name, int numTimes = 1)
{
return HtmlEncoder.Default.Encode($"Hello {name}, NumTimes is: {numTimes}");
}我目前使用的是Visual Studio2017,并安装了.NET Core SDK 2.1.3
有人能帮我解决这个问题吗?
发布于 2017-12-22 01:18:25
艾米评论你的帖子是正确的,你没有使用ASP.Net核心项目/解决方案。
问题是,.Net CoreSDK2.1.3不是相同的asp ASP.Net核心(本教程就是为了这个目的)。

进入此处后,在右上角键入"ASP.Net核心“,如下所示:

然后,您就已经为教程加载了正确的程序集。
https://stackoverflow.com/questions/47929492
复制相似问题