0

My index page in a MVC 5 Application return an unauthorized status code. I have configured my application under IIS 10.0 with none authentication to manage the authentication in the owin pipeline :

<system.web>
    <compilation debug="true" targetFramework="4.7.1" />
    <httpRuntime targetFramework="4.7.1" />
    <authentication mode="None" />
    <pages>
        <namespaces>
            <add namespace="System.Web.Helpers" />
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />
            <add namespace="System.Web.WebPages" />
        </namespaces>
    </pages>
</system.web>
<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
        <clear />
        <add name="Owin" verb="" path="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler, Microsoft.Owin.Host.SystemWeb"/>
    </handlers>
</system.webServer>

Here my controller to allow anonymous on index action :

[Authorize]
public class SPAController : Controller
{
    [AllowAnonymous]
    public ActionResult Index()
    {
        return View();
    }
}

And my owin pipeline where i suspect that i miss something :

// Enable static file serving for the current application before authentication phase
app.UseStaticFiles(new StaticFileOptions() {
    RequestPath = new PathString(""),
    FileSystem = new PhysicalFileSystem(HostingEnvironment.MapPath("~/"))
});

Update

I also tried this without success :

[Authorize]
public class SPAController : Controller
{
    [OverrideAuthorization]
    [AllowAnonymous]
    public ActionResult Index()
    {
        return View();
    }
}

and without attributes

Troopers
  • 3,982
  • 1
  • 29
  • 52

0 Answers0