ASP.NET MVC Default Page

1

Personally I have an ASP.NET MVC application with FormsAutentication and I'm having a hard time leaving a controller as the home page. I already released it in web.config , but it still does not work. The controller is called a website, see the code:

<location path="Site">
<system.web>
  <authorization>
    <allow users="*"/>
  </authorization>
</system.web>

If I type the full address as teste.com.br/Site it works, but if I type only teste.com.br I'm always directed to login page.

<authentication mode="Forms">
  <forms loginUrl="~/Permissao/Login" protection="All" slidingExpiration="false" timeout="60" cookieless="UseCookies"/>
</authentication>
<authorization>
  <deny users="?"/>
</authorization>

In my routeConfig.cs it looks like this:

routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Site", action = "Index", id = UrlParameter.Optional }
        );

But it is always directed to login page instead of Site, if I by the controller Site as Start page in the project property works, but not in the hosting server, only works if setting in the project property, it seems to ignore the rest of the configuration of web.config , route and etc ... Can anyone lend a hand?

    
asked by anonymous 15.07.2016 / 19:34

1 answer

0

You have set up your project so that none Controller is accessible to anyone who is not logged in:

<authorization>
  <deny users="?"/>
</authorization>

Remove these lines from your web.config .

In addition, decorate Controllers that should require login with:

[Authorize]
public class MeuController : Controller { ... }
    
15.07.2016 / 19:51