i'm very new to web development and I have come into a strange error; I am using Visual Studio 2015 along with MVC,
When the code is left in Startup.cs the webpage loads correctly:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
using Microsoft.Extensions.DependencyInjection;
namespace helloworld
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://ift.tt/1y1hxI5
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
app.Run(async (context) =>
{
var html = @"<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2>The World</h2>
</body>
</html>";
await context.Response.WriteAsync(html);
});
}
// Entry point for the application.
public static void Main(string[] args) => WebApplication.Run<Startup>(args);
}
}
However when I take out the HTML between app.Run to await context.Response.WriteAsync(html);
and put it in it's own index file and remove it from startup.cs I get a 404 error. I've set the port to use 8000; I apologise if this is vague and any help would be massively appreciated.
Aucun commentaire:
Enregistrer un commentaire