[英]Error : on the way Controllers/HelloWorldControllers.cs in ASP.NET Core MVC project
我正在尝试转到教程中的以下页面:
https://localhost:44336/HelloWorld/Welcome
我创建了一个 ASP.NET Core MVC Web 应用程序项目,并在Controllers
文件夹中添加了一个名为HelloWorldController
的Controllers
并使用了以下命令而不是以前的命令。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using System.Text.Encodings.Web;
namespace MvcMovie.Controllers
{
public class HelloWorldController : Controller
{
//
// GET : /HelloWorld/
public string Index()
{
return "This is my default action...";
}
//
// GET : /HelloWorld/Welcome/
private string Welcome()
{
return "This is the Welcome action method...";
}
}
}
我遇到的问题是它打开了以下页面:
https://localhost:44336/HelloWorld
但它不会打开以下页面:
https://localhost:44336/HelloWorld/Welcome
请帮我
因为您的Welcome
是private
:
将其修改为public
:
public string Welcome()
{
return "This is the Welcome action method...";
}
关于它们的区别,你可以在这里看到。
当它们是网页时,您的操作不应该是私密的。 你应该把它们公开
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.