0
我仍然試圖讓我的頭圍繞asp.net核心,所以這可能是一個愚蠢的問題,但我不能得到剃鬚刀視圖與asp.net核心mvc 。剃鬚刀視圖與asp.net核心不工作
當我試圖返回一個視圖並沒有在控制檯日誌記錄中獲取任何有用的信息時,出現500錯誤。
我project.json:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
},
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.Extensions.DependencyInjection": "1.0.0",
"Microsoft.AspNetCore.Mvc.Razor": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0"
},
"imports": "dnxcore50"
}
}
}
的Program.cs:
using System;
using System.IO;
using Microsoft.AspNetCore.Hosting;
namespace aspnetcoreapp
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.Build();
host.Run();
}
}
}
Startup.cs:
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.Logging;
namespace aspnetcoreapp
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(LogLevel.Debug);
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
});
app.Run(context =>
{
return context.Response.WriteAsync("Hello from ASP.NET Core!");
});
}
}
}
Home.cs:
using Microsoft.AspNetCore.Mvc;
//using System.Text.Encodings.Web;
namespace MvcMovie.Controllers
{
public class HomeController : Controller
{
//
// GET: /HelloWorld/
public IActionResult Index()
{
return View();
}
//
// GET: /HelloWorld/Welcome/
public string Welcome()
{
return "This is the home Welcome action method...";
}
}
}
我在/Views/Home/Index.cshtml中有一個基本的視圖
任何幫助將不勝感激。
謝謝