문제

I've implmented an service using MVC WEB API and i implemented a custom way to authenticate the requests. this is how it looks like:

public HttpResponseMessage GetTest()
    {
        try
        {                
            IDBModel DAO = new DBModelDAO();
            if (DAO.IsApiKeyValid(Request.Headers.Authorization.Parameter))
            {
                return new HttpResponseMessage(HttpStatusCode.OK);
            }
        }
        catch (Exception e)
        {
            System.Diagnostics.Trace.WriteLine(e.Message);                
        }
        return new HttpResponseMessage(HttpStatusCode.Unauthorized);
    }

However if the authentication fails i get redirected to this uri: /Account/Login?ReturnUrl=%2ftest

And i don't want that because i don't use the webbrowser for authenticating.

How can i disable this feature?

Your help is very much appreciated!

Zoli

도움이 되었습니까?

해결책

The part:

<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>

has to be commented and it won't redirect

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top