Jung
Jung

Reputation: 209

.Net, Azure routes other than index are not working, how do I fix this?

Part of my controller:

    [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();
    }

When I go to "myurl.azurewebsites.net/dragon" It should start this simple dragon game.

However, I get a message that it is unable to handle its request. My "" route (the Index) works fine.

Here is my 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>

Why is my route other than Index not showing up??? Please help me. Thank you.

Upvotes: 0

Views: 74

Answers (1)

Jaya
Jaya

Reputation: 3921

Do not use '\' on your route. Remove the same and it should work. To learn about routes - https://msdn.microsoft.com/en-us/library/cc668201.aspx#routes

Upvotes: 2

Related Questions