Reputation: 1155
I am trying to display a simple "Hello World!" page since I am learning C#. I am coming across an issue where I created the view file and controller, but the view will not display when clicking on "View in browser". Does anyone know what could be the issue? A new browser opens up, but a blank white page is all I get.
This is my DivisionCharts.cshtml file:
@{
ViewBag.Title = "DivisionCharts";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Hello World!</h2>
This is my DivisionsController.cs file:
namespace CProject.Admin.Controllers
{
public ActionResult DivisionCharts()
{
return View();
}
}
Upvotes: 0
Views: 1096
Reputation: 345
At this point you can check the problem in two areas. First, set your default route to this controller and run your project and check the output.
Second, since you are using a layout page and still getting a blank page there might be something wrong with the layout.
Hope this might help.
Upvotes: 0
Reputation: 51
It might just be the "View in Browser" button as mentioned here. You can view your page by running the web application by hitting F5 or the run button in Visual Studio. If you still can't get to your DivisionCharts page you could follow what Hidayat said for routing. A good reference for learning is here
Upvotes: 0
Reputation: 194
You should change the url to Divisions/DivisionCharts
.
You should write controllerName (DivisionController) without the controller part and then /DivisionCharts
If you want the page to work directly change the method name to Index. That is the default page configuration.
Upvotes: 1