0

I am trying to go to the following page in the tutorial:

https://localhost:44336/HelloWorld/Welcome

I created an ASP.NET Core MVC web application project and added a controller called HelloWorldController in the Controllers folder and used the following commands instead of the previous ones.

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...";
        }
    }
}

The problem I have is that it opens the following page:

https://localhost:44336/HelloWorld

But it does not open the following page:

https://localhost:44336/HelloWorld/Welcome

Please help me

2 Answers 2

1

Because your Welcome is private:

Modify it to public:

public string Welcome()
{
    return "This is the Welcome action method...";
}

About the diffence of them you can see here.

Sign up to request clarification or add additional context in comments.

Comments

0

Your action shouldn't be private when they are webpages. You should make them public

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.