.Net,除索引之外的Azure路由都不起作用,我该如何解决这个问题?

时间:2017-09-06 23:08:34

标签: c# asp.net .net azure

我的控制器的一部分:

    [HttpGet]
    [Route("")]
    public IActionResult Index()
    {
        return View();
    }

    [HttpGet]
    [Route("/dragon")]
    public IActionResult Dragon()
    {
        HttpContext.Session.Clear();
        if(HttpContext.Session.GetObjectFromJson<Dachi>("Dachi") == null)
        {
            HttpContext.Session.SetObjectAsJson("Dachi", new Dachi());
        }
        Dachi dachi = HttpContext.Session.GetObjectFromJson<Dachi>("Dachi");
        ViewBag.Fullness = dachi.fullness;
        ViewBag.Happiness = dachi.happiness;
        ViewBag.Meal = dachi.meal;
        ViewBag.Energy = dachi.energy;
        return View();
    }

当我去“myurl.azurewebsites.net/dragon”时 它应该开始这个简单的龙游戏。

但是,我收到一条消息,表示无法处理其请求。 我的“”路线(指数)工作正常。

这是我的web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <system.webServer>
       <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
        </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\logs\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\stdout" forwardWindowsAuthToken="false"/>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

为什么我的路线不是索引不显示??? 请帮我。谢谢。

1 个答案:

答案 0 :(得分:2)

不要在路线上使用'\'。删除相同,它应该工作。要了解路线 - https://msdn.microsoft.com/en-us/library/cc668201.aspx#routes