6
我用一個簡單的MVC控制器和一個簡單的Api控制器創建了一個帶有ASP.NET vnext的非常小的項目。ASP.Net在本地主機上工作的vnext api,在azure上返回404
在本地主機上,一切正常。 如果我部署到蔚藍的網站,只有MVC部分工作
這裏是我的project.json
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"exclude": [
"wwwroot"
],
"packExclude": [
"node_modules",
"bower_components",
"**.kproj",
"**.user",
"**.vspscc"
],
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta2",
"Microsoft.AspNet.Mvc": "6.0.0-beta2"
},
"frameworks" : {
"aspnet50" : { },
"aspnetcore50" : { }
}
}
Startup.cs
using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
namespace Project.Web6
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app)
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
app.UseMvc();
}
}
}
MVC控制器
public class HomeController : Controller
{
// GET: /<controller>/
public string Index()
{
return "Hello world";
}
}
API控制器
[Route("api/[controller]")]
public class MessagesController : Controller
{
// GET: api/values
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
}
的MVC控制器工作正常,但如果我去http://myproject.azurewebsites.net/api/Messages返回404
你是如何部署到天藍色的? – 2015-02-05 18:35:59
如果此鏈接有幫助:https://github.com/aspnet/Home/wiki/Deploy-an-AspNet-vNext-application-to-Microsoft-Azure-websites告訴我發佈它作爲答案:) – astaykov 2015-02-05 20:03:26