asp.net Web表单应用程序中的Web API重定向到登录页面

时间:2016-06-07 07:22:06

标签: c# asp.net authentication asp.net-web-api forms-authentication

在我的asp.net网络表单应用程序中,我在根级别添加了一个文件夹" WebAPI"它有一个web api控制器,它通过令牌进行身份验证。 asp.net web格式应用程序具有表单身份验证。当我从休息客户端调用api时,它会重定向到登录页面。

API响应: -

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/Login/Default.aspx?      ReturnUrl=%2fapi%2fcustomer%2fGetSmsCount">here</a>.</h2>
</body></html>

根级别web.config: -

 <location path="WebAPI"> <system.web> <authorization> <allow users="?"/>
 </authorization> </system.web> </location> <system.web><authorization> 
 <deny users="?" /></authorization> </system.web>

我已经在webapi文件夹上授予匿名访问权限,但仍然会重定向到登录页面。

1 个答案:

答案 0 :(得分:0)

检查您是否给出了正确的API路径