V
V
VladBond2017-09-27 19:14:44
C++ / C#
VladBond, 2017-09-27 19:14:44

ASP.NET MVC not outputting "Hello World"?

We need to quickly get to grips with this technology. I have knowledge of C#, but I am not familiar with applied web technologies.
I write this code in HomeController.cs.

using Microsoft.AspNetCore.Mvc;

namespace PartyInvites1.Controllers
{
    public class HomeContoller : Controller
    {
        public string Index()
        {
            return "Hello world";
        }
    }
}

I expect to see "Hello World", but in the end:
59cbce715c93b297381337.png

Answer the question

In order to leave comments, you need to log in

6 answer(s)
S
SerJook, 2019-06-16
@Gremlin92

std::sort(vector2->begin(), vector2->end(), [](const Type& a, const Type& b) {return a.length > b.length; });

X
xDunin1, 2019-06-17
@xDunin1

vector <int> a;
  for(int i=0; i < a.size(); i++)
  {
     for(int j=0; j < a.size();i++)
      {
          if(a[j] > a[j+1])
          {
                swap(a[j], a[j+1]);
           }
      }
}

E
eRKa, 2017-09-28
@VladBond

The code in the question must be shown in full. in your project

using Microsoft.AspNetCore.Mvc;
namespace PartyInvites.Controllers
{
    public class HomeController : Controller
    {
        public class HomeContoller : Controller
        {
            public ContentResult Index()
            {
                return Content("Hello world");
            }
        }
    }
}

You put another class into the class. In C#, this is allowed, so it does not give any errors. But the Index method will not work in this case. I fixed it like this
using Microsoft.AspNetCore.Mvc;
namespace PartyInvites.Controllers
{
    public class HomeController : Controller
    {
    public string Index()
    {
      return "Hello world";
    }
  }
}

And everything worked great for me.
59cd0738318f7344163527.png

P
Peter, 2017-09-27
@petermzg

The Internet is full of step-by-step implementation examples from scratch. Take advantage of them.

A
Alexey, 2017-09-28
@Eleberet

Norm course on .net mvc, I figured it out myself, everything is step by step and in an extremely accessible language
https://metanit.com/sharp/mvc5

A
Alexander Kuznetsov, 2017-09-28
@DarkRaven

In general, if my memory serves me, then ActionResult should be returned there. In your case, you can do something like this: https://stackoverflow.com/a/553952/2822609
https://msdn.microsoft.com/en-us/library/system.we...
UPD. In this particular case, you can do this:

public ContentResult Index()
{
    return Content("Hello world");
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question